views:

4075

answers:

3

What is the general guidance on when you should use CAST versus CONVERT? Is there any performance issues related to choosing one versus the other? Is one closer to ANSI-SQL?

+5  A: 

Cast is ansi, convert is not.

Brian
Is ANSI-SQL preferable? If so, why?
lush
ANSI-SQL is more portable across database platforms. So if you ever wanted to use the query on Orcale, DB2, etc. The ANSI version is more likely to work without changes.
JohnFx
+5  A: 

Convert has a style parameter for date to string conversions.

http://msdn.microsoft.com/en-us/library/ms187928.aspx

jms
+1 - helpful link. thanks
tyndall
+18  A: 

CONVERT is SQL Server specific, CAST is ANSI.

CONVERT is more flexible in that you can format dates etc. Other than that, they are pretty much the same. If you don't care about the extended features, use CAST.

MatthieuF