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.
Author |
Topic |
12many
Starting Member
9 Posts |
Posted - 2013-03-08 : 12:46:23
|
Hi there I have a field in table one that is a delimited list of codes(a,b,c,d) that relate to data in table 2I have created a @VAR in in my report that readsDECLARE @VAR VARCHAR(50)SET @VAR '''' + REPLACE((SELECT fields FROM table1),',',''',''') + ''''So the Value in @Var will read 'a','b','c','d'What i was then hoping to be able to do is SELECT Data FROM Table2 WHERE Code IN (@VAR)It has come to my attention this is not possible Can any one give any advise on how this can be achievedIan |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
12many
Starting Member
9 Posts |
Posted - 2013-03-14 : 06:46:59
|
Hi visakh16Thanks Alot for this, Ill give it a bash when i get a chance,Ian |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2013-03-14 : 09:28:29
|
why not just store the values in table1 properly (i.e. 1 per row) then simply use SELECT Data FROM Table2 WHERE Code IN (select field from table1)? |
|
|
|
|
|