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 |
|
zubamark
Starting Member
23 Posts |
Posted - 2008-01-24 : 10:32:06
|
| Hi,How to send multi data in one variable.EXEC ABC '01/20/2008','1,2,3,4' CREATE PROCEDURE ABC@Date datetime,@Status varchar(50)ASselect * from T1 where Date=@Date and Status in(@Status) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-24 : 10:48:14
|
| Keep in mind that you cant use variable inside in. You need to use dynamic SQL or your statement should be as follows:-select * from T1 where Date=@Date and @Status like '%' + CAST(Status AS varchar(2)) + '%'assuming Status is of type int. |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2008-01-24 : 10:54:14
|
| To get good performance, it's a good idea to create a temp table (or table variable, but you can't create an index on a table variable) and parse through the list and put those values in the temp table.Temp Table:Status1234Then you can just join to your temp table in your query. |
 |
|
|
zubamark
Starting Member
23 Posts |
Posted - 2008-01-24 : 11:07:21
|
| How to EXEC ABC '01/20/2008','TempTable'? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-24 : 11:10:51
|
| pass values as a string and inside SP get values from string onto temp table. You can even use a user defined function for achieving this. then you may take join with UDF to get results filetered. The UDF can be found out inside these forums. Search for it.Else pass as a string and use LIKE as i suggested. |
 |
|
|
zubamark
Starting Member
23 Posts |
|
|
|
|
|