Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Difference between CAST and CONVERT

Author  Topic 

deepakugale
Starting Member

33 Posts

Posted - 2010-05-11 : 02:28:57
What is difference between CAST and CONVERT ?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-11 : 03:22:08
Apart from the datetime formatting capabilities of CONVERT, CAST and CONVERT do identical jobs.

http://www.sqlservercentral.com/Forums/Topic487723-8-1.aspx#bm488058


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-11 : 03:47:43
Also CAST is ANSI standard and CONVERT is not

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-11 : 03:49:56
" Apart from the datetime formatting capabilities of CONVERT"

... and Money ... and others

Personally, because I sometimes use CONVERT for its formatting ability, I never use CAST so that I don't wind up with a mix of the two.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-11 : 03:52:32
quote:
Originally posted by Kristen

" Apart from the datetime formatting capabilities of CONVERT"

... and Money ... and others

Personally, because I sometimes use CONVERT for its formatting ability, I never use CAST so that I don't wind up with a mix of the two.


I use usually CAST and use CONVERT whenever the front-ends don't do the formations

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-11 : 06:15:46
That's a reasonable approach (although I'd prefer "I always use CAST except when I need to force the format")

I find the CAST syntax harder to read quickly.
Go to Top of Page
   

- Advertisement -