Sqlparameter with "IN " sintaxe

  • Thread starter Thread starter João Santa Bárbara
  • Start date Start date
J

João Santa Bárbara

Hi all
i have this query .
Ex: "Select * from tblMove Where ID IN (1,2,3,4,5) and i want to replace
the "1,2,3,4,5" with a parameter.
is it Possible ?!

thlks
JSB
 
Hi all
i have this query .
Ex: "Select * from tblMove Where ID IN (1,2,3,4,5) and i want to replace
the "1,2,3,4,5" with a parameter.
is it Possible ?!

thlks
JSB

You could certainly replace the 1,2,3,4,5 with 5 parameters but I'm
thinking you may not want that. Is it not possible to have the
1,2,3,4,5 be a select from some other table with a fixed number of
parameters? In my cases, I always seem to be able to make that happen.

Good Luck.
Peter Kellner
http://peterkellner.net
 
No, I actually enjoy string parsing, extra temp tables and some slightly
complex T-Sql. I can babble stuff like "Another implementation involves
using Table variables..." and all the new guys think I'm smart ;-) Probably
ought to start spending my time getting good at LINQ instead ;-)
Miha Markic said:
Doesn't it suck - not being able to pass an array to sql server.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

W.G. Ryan - MVP said:
Try this approach
http://support.microsoft.com/default.aspx?scid=kb;en-us;555167

Since params are escaped, you're going to have to break the list apart at
some point, but the above example I wrote does it in a fairly simple
fashion and has been used quite a bit. If you have any questions, let me
know.

Cheers,

Bill
 
Right, but that wasn't the question. It was whether or not you could do it
as a parameter.
 
That is what I meant. You pass it as a parameter, then use it in dynamic
SQL.

Obviously

Jeff
 
Back
Top