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
 Transact-SQL (2005)
 Stored procedure not working

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-02-12 : 09:39:55
What am I missing? I'm not getting any results:

declare @doc varchar(300)
select @Doc = '"300","200"'
select * from iclaims
where doc in(@Doc)

I want the user to be able to enter in two choices for a DOC so they could enter 300, 200. I need the comma in between.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-12 : 09:41:05
quote:
Originally posted by JJ297

What am I missing? I'm not getting any results:

declare @doc varchar(300)
select @Doc = '"300","200"'
select * from iclaims
where doc in(@Doc)

I want the user to be able to enter in two choices for a DOC so they could enter 300, 200. I need the comma in between.




Did you search for it?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 09:48:10
quote:
Originally posted by JJ297

What am I missing? I'm not getting any results:

declare @doc varchar(300)
select @Doc = '"300","200"'
select * from iclaims
where doc in(@Doc)

I want the user to be able to enter in two choices for a DOC so they could enter 300, 200. I need the comma in between.



it should be

declare @doc varchar(300)
select @Doc = '300,200'
select * from iclaims
where ',' + @Doc + ',' LIKE '%,' + CAST(doc AS varchar(10)) + ',%'
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-12 : 09:54:06
Read http://www.sommarskog.se/arrays-in-sql-2005.html



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

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-02-12 : 10:00:11
Thanks Visakh16 that's it.

Thanks Peso for the documentation this is helpful!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 10:07:35
welcome
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-12 : 10:19:33
Good luck!



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

- Advertisement -