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 |
|
companionz
Yak Posting Veteran
54 Posts |
Posted - 2009-04-17 : 08:57:08
|
| Guys,I am passing this value to a procedure as an input parameter:'300617901GB7~300617901GB8~300617901GCF'and inside am making it as :'300617901GB7','300617901GB8','300617901GCF'and then passing it to a select query:Select * from TestTable where TestNumber in (@SLNumberFinal) But this doesn't return me any value...but if i pass a parameter to proc like this '300617901GB7' it gives a value..I did check for this value and it is getting passed to the sql query as : 300617901GB7i mean with no inverted commas.. i even tried passing :300617901GB7','300617901GB8','300617901GCFCan anyone help me resolve this issue?Thanks,Sourav |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-17 : 09:04:53
|
| Select * from TestTable where '~'+@SLNumberFinal+'~' like '%~'+TestNumber+'~%'MadhivananFailing to plan is Planning to fail |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-04-17 : 23:13:44
|
| try this one toodeclare @str varchar(128)set @str ='300617901GB7','300617901GB8','300617901GCF'exec('Select * from TestTable where testnumber in ('+@str+')') if testnumber is integer value use this oneexec('Select * from TestTable where cast(testnumber as varchar(128) in ('+@SLNumberFinal+')') |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-18 : 02:54:56
|
quote: Originally posted by bklr try this one toodeclare @str varchar(128)set @str ='300617901GB7','300617901GB8','300617901GCF'exec('Select * from TestTable where testnumber in ('+@str+')') if testnumber is integer value use this oneexec('Select * from TestTable where cast(testnumber as varchar(128) in ('+@SLNumberFinal+')')
That wont work. In this approach, you need to put single quote around each valueMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|