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 |
|
ranalk
Starting Member
49 Posts |
Posted - 2010-05-13 : 01:23:34
|
| Hi,I will give and example of my current case:DECLARE @NAME VARCHAR(15)SET @Name = ''SET TRANSACTION ISOLATION LEVEL SNAPSHOTSELECT * FROM Employee eWHERE e.Name = @NameI want to pass few name in the same time, so how can I put it into the one parameter?i want it to run in the following format:DECLARE @NAME VARCHAR(15)SET @Name = SET TRANSACTION ISOLATION LEVEL SNAPSHOTSELECT * FROM Employee eWHERE e.Name IN @NameThanks! |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-05-13 : 01:28:27
|
| Use Dynamic SQLDECLARE @NAME VARCHAR(15)SET @Name = '''a'',''b'''exec ('Select * from Employee e where e.name in ('+@Name+')')Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-05-13 : 01:29:39
|
| i think you can use comma separated variables....i have used it to pass multiple values into the parameters. write a function to split the data as CSV and then write : WHERE @Name in (select from that SPLIT Function) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-13 : 10:52:29
|
or simply doSELECT * FROM Employee eWHERE ',' + @Name + ',' LIKE '%,' + e.Name + ',%' and pass value in csv format------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|