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
 SQL Server Development (2000)
 using "in" in a select

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-05-21 : 03:37:30
i am doing a query on a table
where i have c column user_pid nvarchar(10).
when i do a select like :
select * from tbl1 where user_pid in (012345678,654123547)
i recive an error that tells me that '000000000' cant be converted to data type int?!?!?!
(i know that there is a user_pid= '000000000'
but why does it make me prolbmes with the query?
what can i do?
thnaks i nadvance
peleg


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2006-05-21 : 03:51:27
quote:
Originally posted by pelegk2

i am doing a query on a table
where i have c column user_pid nvarchar(10).
when i do a select like :
select * from tbl1 where user_pid in (012345678,654123547)
i recive an error that tells me that '000000000' cant be converted to data type int?!?!?!
(i know that there is a user_pid= '000000000'
but why does it make me prolbmes with the query?
what can i do?
thnaks i nadvance
peleg


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)



Try

select * from tbl1 where Cast(user_pid as int) in (012345678,654123547)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-21 : 04:38:51
[code]select * from tbl1 where user_pid in ('012345678','654123547')[/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-23 : 02:22:22
>>select * from tbl1 where Cast(user_pid as int) in (012345678,654123547)

That will lead to error if user_pid has alphabets

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -