Some time we requite
select * from tbl where id in (1,2,3)
if we try like that
declare @csv varchar(20)
select * from tbl where id in (@csv )
Ooops.... error
what's wrong with this...
if you try to print this query you will get the query
select * from tbl where id in ('1,2,3')
error because @csv cannot be converted to int
There is a simple way to resolve this
exec ('select * from tbl where id in ( ' + @csv + ')' )
Cheers!
Mahesh
maheshsingh21@hotmail.com
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions