Showing posts with label convert. Show all posts
Showing posts with label convert. 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...
>

Sunday, February 19, 2012

Developer cant handle dates

Do I have to convert dates for a .NET developer so they can capture ms?
Or is there a method they are suppose to be using
I had to remove my modified date check to check for data collisions because they can't pass back microseconds.
What's the dealDepending on which of the .NET languages is being used, and in most of them which data type is being used, temporal data can be stored to the day, second, or true millisecond (which is actually more precise than SQL Server can store).

The short answer becomes something like: If you want absolute portability, convert and send them text (character) data. If they are using C#, C++, or VB then they just have to choose the correct data type. Most of the other .NET languages can store times to millieconds, but depending on the language that can be a pain in the patoot.

-PatP|||This dodges the obvious bullet about most developers not being able to even get a date, much less handle one! ;)

-PatP|||i thought this was a craigslist post.|||OK, CONVERT it is

And why is sql server limited in th MS category?

Something about clock speed?