PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Re: multiple entries in a parameter

Reply

Re: multiple entries in a parameter

 
Thread Tools Rate Thread
Old 05-01-2007, 05:14 PM   #1
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: multiple entries in a parameter


SQL Server's TSQL does not (directly) support parameters for the IN
expression. As described in the CLR chapter, you can create a TSQL
table-value function that accepts a delimited list and extrudes a SQL Table
that CAN be passed to the IN expression. This can also be done in about 5
lines of code in CLR (and about 30 lines in TSQL).

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"T McDonald" <TMcDonald@discussions.microsoft.com> wrote in message
news7B8F21D-01EE-4142-A0E1-47D0A087DA75@microsoft.com...
>I have a question with how to accomplish the following. I generate a list
>of
> values from a text/XML file. I would like to then filter a query on a SQL
> table with that data similar to the following:
>
> delete from mytable where xyz not in (mylist)
>
> Where the hashtable is the contents I've just generated from the XML data
> (not everything is kept from the XML data). My first thought is to create
> a
> comma-delimited list and add that as a parmeter like this:
> delete from mytable where xyz not in (@mylist)
>
> I'm wondering if there is a more efficient way to do this with .NET. i.e.
> some way to add multiple entries to the parameter.
>
> Thanks for any help.



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off