Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delimited String to Multiple Records In Stored Proc.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all I hope someone can help me.

I have a stored procedure that inserts data into multiple tables. I am wanting to parse a comma delimited string and insert new records for each element. i.e

@year1content = french,german,maths,ecnomics...
(from textarea form field)
@CourseID = @@IDENTITY (from autonumber in main table)

---------------------------------------------------------
SET @CourseID = @@IDENTITY

--insert into year1 Table

INSERT INTO Year1 (CourseID, Content)

VALUES (@CourseID, @year1content) -- I need a loop here?

Return

-------------------------------------
To give me:

Year1
-------------------
ID Content
------------------
2 french
2 german
2 maths
2 economics

Thanks in Advance. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top