Pro Programmer: cast and convert

Wednesday, August 15, 2012

cast and convert


cast and convert-- converts an expression from one data type to another.
cast and convert have similar functionality. However, Cast is Ansi Standard, while Convert is for sql server only and convert has more functionality and is mainly used for date/time functions.


Although their performance is also similar, their syntax and potential usage is slightly different.

Syntax for CAST:
CAST ( expression AS data_type [ (length ) ])
Syntax for CONVERT:
CONVERT ( data_type [ ( length ) ] ,expression [ ,style ] )





No comments:

Post a Comment