Showing posts with label cast. Show all posts
Showing posts with label cast. Show all posts

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.

Wednesday, March 21, 2012

diff between Cast and Convert

what is the diff between cast and convertCONVERT function has a parameter called style.
"Subramaniyan Ramesh" <SubramaniyanRamesh@.discussions.microsoft.com> wrote
in message news:353A3CCC-9CA1-4AEF-877A-F99F5EA7AA5D@.microsoft.com...
> what is the diff between cast and convert|||I believe also that CAST is part of standard SQL, but CONVERT is
specific to SQL Server.
Roy
On Thu, 20 Apr 2006 13:35:20 +0300, "Uri Dimant" <urid@.iscar.co.il>
wrote:

>CONVERT function has a parameter called style.
>"Subramaniyan Ramesh" <SubramaniyanRamesh@.discussions.microsoft.com> wrote
>in message news:353A3CCC-9CA1-4AEF-877A-F99F5EA7AA5D@.microsoft.com...
>|||I'd say specific to deal with DATES :-))
"Roy Harvey" <roy_harvey@.snet.net> wrote in message
news:dmqe42ppseg2s2hualu068dls4c9kg7po6@.
4ax.com...
>I believe also that CAST is part of standard SQL, but CONVERT is
> specific to SQL Server.
> Roy
>
> On Thu, 20 Apr 2006 13:35:20 +0300, "Uri Dimant" <urid@.iscar.co.il>
> wrote:
>|||CONVERT has existed since 1.0. CAST was introduced in some later version (6.
0 or 7.0, I'm not sure).
Roy is correct that CAST is ANSI SQL. And I also agree that *if* you want to
do date formatting in
SQL Server, then CONVERT is the one to use.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Uri Dimant" <urid@.iscar.co.il> wrote in message news:elJzEuGZGHA.3444@.TK2MSFTNGP05.phx.gbl
..
> I'd say specific to deal with DATES :-))
> "Roy Harvey" <roy_harvey@.snet.net> wrote in message
> news:dmqe42ppseg2s2hualu068dls4c9kg7po6@.
4ax.com...
>

Friday, March 9, 2012

Devide by zero error

help please.
I have sql statement that cast two date range into decimal and then devive
by one another.
When I compile this code I get error: Source: Microsoft OLE DB provider for
sql
Error desc: Devide by zero error encountered.
How would I resolve this issue?Please disregard. I found a thread that already had the answer.
search for : Divide by Zero
"ITDUDE27" wrote:

> help please.
> I have sql statement that cast two date range into decimal and then devive
> by one another.
> When I compile this code I get error: Source: Microsoft OLE DB provider fo
r
> sql
> Error desc: Devide by zero error encountered.
> How would I resolve this issue?