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)
 delimited list and "in" command

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2009-12-16 : 06:51:53
i have a Store Procedure, which recive XML.
i open this XML using openxml, and setting the fileds into variables.
one of the variables recive a delimited list :
@xxx='a,b,c'
after it i want to use it in a query like :
select * from table1 where col1 in (@xxx)
the problem is that the @xxx is not a table but rather a string,
which not helps me.
is there a way when i get the value from the xml to @xxx to convert it to a table, or i rather have to do something like

[url]http://sqlservernation.com/blogs/howtos/archive/2009/03/07/converting-a-delimited-string-into-a-table.aspx[/url]

Thanks
Peleg

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-16 : 07:04:52
select * from table1 where ,'+@xxx+',' like '%,'+col1 +',%'

Madhivanan

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

- Advertisement -