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 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2007-06-16 : 10:37:52
|
| Dear Friend, I got a problem in selecting few records from a Table Using Stored Procedure. To Select all Records we use following command Select * from Tbl_StudentTo get Selected Records we use following Sql Statementselect * from Tbl_Student where StudentId in (11,50,25,50)Note: StudentId is an Int Column. My query is how to Do the same task in stored procedureby sending 11,50,25,50 as a single parameter.With RegardsOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
ranganath
Posting Yak Master
209 Posts |
Posted - 2007-06-19 : 00:28:00
|
| Hi,Declare @str varchar(100)Set @str = '1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24'select * from Tablename where ',' + @str + ',' Like '%,' + cast(columnname as varchar(100))+ ',%'Here Columnname means which column u want to split |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-20 : 04:26:30
|
| orcharindex(',' + @str + ',',',' + cast(columnname as varchar(100))+ ',')>0MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|