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 2005 Forums
 Other SQL Server Topics (2005)
 IN FUNCTION

Author  Topic 

kurtgr
Starting Member

25 Posts

Posted - 2009-06-11 : 08:56:47
Hello All

SELECT * FROM RequestPendingView Where 4608 IN (WelfareManager)

I am trying to select all records from a view where '4608' is in column welfaremanager. The data which is in the column looks like this 4608,4701

When i run the requery i get this
Conversion failed when converting the varchar value '4608, 4701

If I put 4608 ('4608') in quotations the result set is blank.

Can someone tell me what am i doing wrong

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-11 : 08:58:22
SELECT * FROM RequestPendingView Where ',' + WelfareManager + ',' LIKE '%,4608,%'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

kurtgr
Starting Member

25 Posts

Posted - 2009-06-11 : 11:09:55
Thanks for your responds it works with 4608 but when I try it with 4701 I get no result

Again Thanks in advance
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-11 : 12:08:24
That's because you have space between comma and number!

SELECT * FROM RequestPendingView Where ',' + REPLACE(WelfareManager, ' ', '') + ',' LIKE '%,4701,%'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

kurtgr
Starting Member

25 Posts

Posted - 2009-06-12 : 14:46:53
Thanks for your assistance it worked quite well.
Go to Top of Page
   

- Advertisement -