February 21, 2005 at 7:14 am
Hi,
Is there any function in MS SQL server 2000 to convert a string value to an equivalent integer value? ( i.e. an equivalent of atoi() in C languge defined in <stdlib.h>
Or How can I store a hexadecimal number in SQL server and use them in comparison operations like the one given below:
> CREATE TABLE NumTest (StartNumber varchar(10),EndNumber varchar(10))
>INSERT INTO NumTest (StartNumber, EndNumber ) VALUES (100,199)
>INSERT INTO NumTest (StartNumber, EndNumber ) VALUES (200,299)
>INSERT INTO NumTest (StartNumber, EndNumber ) VALUES (3FF,5FF) -- 3rd row is having hexadecimal values.
When I run the following query I am getting the result with error:
>SELECT * FROM NumTest WHERE CAST(StartNumber AS INT) >100
StartNumber EndNumber
----------- ----------
200 299
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '3FF' to a column of data type int.
Actually I need to get the row with 3FF..
Thanks in advance.
Unnic
February 21, 2005 at 7:29 am
Lots of useful ideas here:
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply