If you are using SQL Server, you could use OPENXML to do your insert from a
list. 

You will have to convert your list into XML and pass to your SP as  a
varchar datatype. Lets say that param is @myIds

Then in your SP, you could do something like this:


DECLARE @hDoc int
exec sp_xml_preparedocument @hDoc OUTPUT,@myIds

INSERT INTO mytable(columnname)
SELECT dcId FROM OPENXML (@hdoc, '/data/Ids', 1) WITH (dcId int)

EXEC sp_xml_removedocument @hDoc




This is assumuing your xml is of the form:

<data>
<Ids dcId="17"></Ids>
<Ids dcId="13"></Ids>
<Ids dcId="61"></Ids>
</data>

HTH,
Dharmendar Kumar


-----Original Message-----
From: Alberto Cuellar [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 28, 2007 11:49 PM
To: SQL
Subject: Re: Inserting data from a muliple select list into database


> James,
> 
> The value of your multiple select is passed as a list.
> You can loop through the values and insert them into
> the database:
> 
> <CFLOOP LIST="#FORM.MySelectList#" INDEX="i">
> <CFQUERY NAME="qInsertSelection" DATASOURCE="...">
> INSERT INTO mytable
>       (column)
> VALUES
>       (#i#)
> </CFQUERY>
> </CFLOOP>
> 
> Good luck,
> Beau
> 
> 
> -----Original Message-----
> From: James Taavon [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 19, 2001 12:47 PM
> To: SQL
> Subject: Inserting data from a muliple select list into database
> 
> 
> I have a CFSELECT that has the option to select one or multiple items
> in
> a
> dynamic drop down list. If a user selects more than one how do I 
> insert
> that
> into the database?
> 
> 
> 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Hi, My question is how can i do the insertion but in different rows, I 
> mean i
want to insert each item of the select list in a new row, how can I do that?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2827
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6

Reply via email to