Possible Duplicate:
T-SQL Cast versus Convert
What is the major difference between CAST
and CONVERT
in SQL cause both performs data type conversion?
Possible Duplicate:
T-SQL Cast versus Convert
What is the major difference between CAST
and CONVERT
in SQL cause both performs data type conversion?
CAST and CONVERT have similar functionality. CONVERT is specific to SQL Server, and allows for a greater breadth of flexibility when converting between date and time values, fractional numbers, and monetary signifiers. CAST is the more ANSI-standard of the two functions. Check this blog for examples of using both of those: http://sqltutorials.blogspot.com/2007/06/sql-cast-and-convert.html
The convert
function can do more complex conversions, for example converting a datetime
value into varchar
using a specific format:
convert(varchar(16), dateTimeValue, 120)
Assuming you're talking about SQL Server.
From http://msdn.microsoft.com/en-us/library/ms187928.aspx and http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx
Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.
So yes, they are functionally the same. They just have different syntax that allows for more complex conversions or (subjectively) improved readability.