Sunday, March 25, 2012

difference between cast and convert in SQL

Can anyone explain in simple terms the difference between cast and convert in SQL?

They pretty much do the same thing. If you're just changing data from one form to another for use, such as changing a "45" from a varchar to an int, use CAST; Convert offers more options than cast which may lead to more processing time. And by this, I of course mean MINIMAL, not noticeable processing time. Convert allows you to add a format style to your convertion, if you want it to. For example, if you're changing a date to a string, you can say which part of the date to return instead of returning the whole thing and making .NET format it.

Here's thehelp page.

|||

Hi,

From your question, I just suggest you refer the following material

http://msdn2.microsoft.com/en-us/library/ms187928.aspx

Hope it helps.

No comments:

Post a Comment