Groups | Blog | Home
all groups > dotnet ado.net > may 2006 >

dotnet ado.net : Sqlparameter with "IN " sintaxe


Jeff Dillon
5/19/2006 10:17:54 AM
Well, you could using Dynamic SQL

Jeff
[quoted text, click to view]

Marina Levit [MVP]
5/19/2006 12:45:42 PM
No.

[quoted text, click to view]

João Santa Bárbara
5/19/2006 5:41:58 PM
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

PeterKellner
5/20/2006 5:38:14 PM
On Fri, 19 May 2006 17:41:58 +0100, "João Santa Bárbara"
[quoted text, click to view]

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
W.G. Ryan - MVP
5/22/2006 8:09:46 AM
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
[quoted text, click to view]

Jeff Dillon
5/22/2006 2:57:04 PM
That is what I meant. You pass it as a parameter, then use it in dynamic
SQL.

Obviously

Jeff
[quoted text, click to view]

W.G. Ryan - MVP
5/22/2006 3:26:46 PM
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 ;-)
[quoted text, click to view]

Miha Markic [MVP C#]
5/22/2006 3:38:18 PM
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/

[quoted text, click to view]

Marina Levit [MVP]
5/22/2006 4:48:01 PM
Right, but that wasn't the question. It was whether or not you could do it
as a parameter.

[quoted text, click to view]

AddThis Social Bookmark Button