Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 comparing varchar

Author  Topic 

tran008
Starting Member

38 Posts

Posted - 2004-06-23 : 12:39:29
Hi all,

I'm trying to get the following to equal but unable to get anywhere.
'1234567890'=' 1234567890'. Try ltrim(), cast()and convert() but was unable to get result.

thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-23 : 13:06:34
select 1 where '1234567890' = ltrim(' 1234567890')
select 1 where convert(int,'1234567890') = convert(int,' 1234567890')


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

tran008
Starting Member

38 Posts

Posted - 2004-06-23 : 15:28:51
I get the follow error when using convert :

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value ' 6099210222' to a column of data type int.

Server: Msg 248, Level 16, State 1, Line 1
The conversion of the varchar value '7323601000' overflowed an int column. Maximum integer value exceeded.

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-23 : 16:26:45
You'll need to use bigint instead. You are outside the range of what int data type supports.

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-06-23 : 16:45:02
Why bother


SELECT 1 WHERE REPLACE('1234567890',' ','') = REPLACE(' 1234567890',' ','')




Brett

8-)
Go to Top of Page
   

- Advertisement -