Thursday, July 29, 2010

CAST vs CONVERT

Both these functions are used to convert values from one datatype to another
But there are some differences between them

1 CAST is ANSI standard and CONVERT is specific to SQL Server
2 CAST can't be used for formating purposes.
But CONVERT can be used for formating purposes particularly on datetime and money datatype

declare @d datetime
set @d='20001210 12:34:22'
select convert(varchar(10),@d,108)
declare @m money
set @m=23498
select convert(varchar(10),@m,1)

Read more: Beyond Relational

Posted via email from .NET Info