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 |
|
anujpratap84
Starting Member
45 Posts |
Posted - 2011-02-15 : 11:09:23
|
| Hi All,I am passing comma separated ids to a varchar variable in SP using C#. SP query like:Select * From player Where ID IN('1')It's working fine for a single record but if record is more than 1 Like '1,2,3,4' it throws an error on converting '1,2,3,4' to data type int.Can i remove single code from this.I don't want to use dynamic query.Any body have any idea.Thanks in advance.Anuj Pratap Singh |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-15 : 11:29:47
|
| Yes. and the error is quite clear as you are trying to compare a string value with an Integer column. its good to avoid Dynamic SQL for such operation and as an alternative you should implement CSV to table conversion ... google the highlighted you will get a good details. |
 |
|
|
anujpratap84
Starting Member
45 Posts |
Posted - 2011-02-15 : 13:03:54
|
quote: Originally posted by MIK_2008 Yes. and the error is quite clear as you are trying to compare a string value with an Integer column. its good to avoid Dynamic SQL for such operation and as an alternative you should implement CSV to table conversion ... google the highlighted you will get a good details.
Thanks you, MIK_2008.Anuj Pratap Singh |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-16 : 09:39:08
|
| or pass ids to variable @id and useSelect * From player Where '%,'+@id+',%' ','+cast(ID as varchar(10))+','MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|