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 |
|
CLages
Posting Yak Master
116 Posts |
Posted - 2005-01-07 : 11:36:15
|
| hi , this script works well, but if i use using the comment linei get nothingwhere is my mistakeTksCarlos LagesSET QUOTED_IDENTIFIER OFFdeclare @tpfat char(200)set @tpfat = "'601', '701'"SELECT * FROM MOVIMENT WHEREMOV_TPFATURA IN ('601', '701')--MOV_TPFATURA IN (@tpfat) |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-07 : 11:52:33
|
| @tpfat is a single string so your test is actually an =.' is a string delimitter not "set @tpfat = '''601'', ''701'''declare @tpfat varchar(20)set @tpfat = '''601'', ''701'''declare @sql varchar(1000)select @sql = 'SELECT * FROM MOVIMENT WHERE MOV_TPFATURA in (' + @tpfat + ')'exec (@sql)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
CLages
Posting Yak Master
116 Posts |
Posted - 2005-01-07 : 11:53:07
|
| I saw in BOL that i can only use CONSTANT in the expression INbut in this case how can i use IN , in a Stored Procedure ?In other words i need to pass '601, '701, etc into a String as parameter to the SPbecause i can only pass variable as Parameterhow can i fix itTks againC. Lages |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-07 : 12:04:44
|
| see the code I posted.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|