Sunday, February 12, 2012

char to integer ?

Does anyone know how can i change the character into interger ?
like "1" ->> 1
thanksUse CONVERT(). See BooksOnLine for more details but this is the idea:
SELECT CONVERT(INT, '1')
Andrew J. Kelly SQL MVP
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:OEOjJ$1SGHA.2276@.tk2msftngp13.phx.gbl...
> Does anyone know how can i change the character into interger ?
> like "1" ->> 1
> thanks
>|||Or use CAST which is the ANSI-compliant version ( ie make your code more
portable ):
SELECT CAST( '1' AS INT )
There's no real difference in the results but CONVERT is what's called a
T-SQL extension, ie Microsoft made it up, and it can take an extra argument
for returning a formatted date. As to whether you should be formatting date
s
server-side is a _whole_ different argument ( Hey Joe! ) ; )
Hope that helps!
Damien
"Andrew J. Kelly" wrote:

> Use CONVERT(). See BooksOnLine for more details but this is the idea:
> SELECT CONVERT(INT, '1')
>
> --
> Andrew J. Kelly SQL MVP
>
> "Agnes" <agnes@.dynamictech.com.hk> wrote in message
> news:OEOjJ$1SGHA.2276@.tk2msftngp13.phx.gbl...
>
>

No comments:

Post a Comment