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)
 What is the difference between CAST and CONVERT

Author  Topic 

baburk
Posting Yak Master

108 Posts

Posted - 2009-06-11 : 07:58:45
Hi,

What is the difference between CAST and CONVERT?.

Can anybody explains in detail.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-11 : 08:01:16
Not much.
CAST seems to be somewhat faster but offers less options.
CONVERT has a lot of options.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-06-11 : 08:10:01
Is CAST more a vanilla SQL keyword and CONVERT more a TSQL one?

(kinda like COALESCE and ISNULL -- though I know you can do some crazy stuff with COALESCE)

I pretty much always use CAST as I like the syntax. Only use CONVERT rarely.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

andrewz00
Starting Member

15 Posts

Posted - 2009-06-11 : 12:12:50
i like using convert and cast together to strip time from a datetime field or if i want to display AM/PM etc... other then that i almost always use cast.
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-06-11 : 13:36:49
WOW thats hard

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL or How to sell Used Cars
For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -