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 |
|
stineco
Starting Member
6 Posts |
Posted - 2005-06-06 : 11:13:49
|
| Hi am trying to use thisdeclare @blp1 char(24) set @blp1 = ('002','003')select distinct c.opmerking, c.omschrijving, c.em_id , eq.eq_id, eq.dp_id, eq.bl_id, eq.fl_id from controle as c inner join eq on eq.dp_id=c.dp_id where c.em_id like 'boon%' and eq.bl_id in (@blp1) This isn't workingHow can i use the IN statement |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-06 : 11:15:38
|
http://www.sqlteam.com/item.asp?ItemID=11499Go with the flow & have fun! Else fight the flow |
 |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-06-06 : 21:09:10
|
or the easiest way is to use dynamic SQLdeclare @blp1 char(24) declare @sql varchar(1000)set @blp1 = ('002,003,005')set @sql = 'select distinct c.opmerking, c.omschrijving, c.em_id , eq.eq_id, eq.dp_id, eq.bl_id, eq.fl_id from controle as c inner join eq on eq.dp_id=c.dp_id where c.em_id like 'boon%' and eq.bl_id in ( ' + @blp1 + ')'EXEC @sql"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. " raclede |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-06-07 : 07:57:05
|
| Try this i hope this should work for u declare @blp1 char(24) set @blp1 = ' ''002'',''003'' 'select distinct c.opmerking, c.omschrijving, c.em_id , eq.eq_id, eq.dp_id, eq.bl_id, eq.fl_id from controle as c inner join eq on eq.dp_id=c.dp_id where c.em_id like 'boon%' and eq.bl_id in (@blp1) if this will work if ur bl_id is the char or varchar field... for numeric datatype it wont workComplicated things can be done by simple thinking |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
|
|
|
|
|