Here is a stored procedure I wrote awhile back, hopefully it is some use to
you.. it takes in a comma delimited list (you can change the delimiter if
need be) and does an insert for each element in the list:
This is just a section of it... you will have to alter it to get it to work,
but not much.
ALTER procedure sp_AssociateMMS
(
@HazardID int,
@list varchar(1000),
@UserID int
)
AS
SET NOCOUNT ON
DECLARE @separator_position int
DECLARE @list_value varchar(1000)
DECLARE @separator char(1)
SET @separator = ','
IF @list != 'empty'
BEGIN
SET @list = @list + @separator
END
----------------------------------------------------
-- If the list passed in is not empty, loop through
-- it and insert each MMS ID into the HazMMSLink
-- table
----------------------------------------------------
WHILE patindex('%' + @separator + '%' , @list) <> 0
BEGIN
SELECT @separator_position = patindex('%' + @separator + '%' , @list)
SELECT @list_value = left(@list, @separator_position - 1)
IF @list_value != '' OR @list_value != ','
BEGIN
INSERT INTO HazMMSLink(Haz_ID, MMS_ID, Record_Change_User_ID)
VALUES(@HazardID,@list_value,@UserID)
END
SELECT @list = stuff(@list, 1, @separator_position, '')
END
COMMIT TRAN add_mms
END
----- Original Message -----
From: "Boldacious Web Design" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, June 07, 2003 8:57 AM
Subject: inserting a list
> Hi
>
> I have a list of images image01.jpg, image02.jpg, image03.jpg
> associated with one stock record eg 1045
> I want to insert these into a table like so:
> 1045 - image01.jpg
> 1045 - image02.jpg
> 1045 - image03.jpg
>
> Can anyone help me with the code for this please?
> Seamus
>
>
> Seamus Campbell Boldacious WebDesign
> http://www.boldacious.com ~~~~ [EMAIL PROTECTED]
> ph 02 6297 4883 fax 02 6297 8464 mob 0410 609 267
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at
http://www.coolfusion.com
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4