Saturday, February 18, 2012

Difference between CAST and CONVERT

In SQL SERVER we have both the CAST keyword, and the CONVERT keyword. Are there any differences?

The difference is simply one of naming.
CONVERT is local to SQL Server, and has great flexibility when using it with date, time, fractional numbers and money values.

CAST is the more ANSI-standard, making it more portable. Use CAST to convert between decimal and numeric values, since it is more loyal to precision.

The beauty of standards, is how many of them there are.

No comments: