Monday, November 29, 2010

Difference between cast() and convert() in sql server 2005.

Both function are used in Sql server for explicit conversion of data from one data type to another data type. But using convert() function , data will convert in formated manner , not in cast() function.
For Example:-
cast()
cast(data as datatype)
select cast(getdate() as varchar(100))
output -- Nov 29 2010  5:39PM


convert()
convert(datatype,data,formate)
select  convert(varchar,getdate(),105)
output -- 29-11-2010

No comments:

Post a Comment