Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 New Records from comma delimited string

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-19 : 10:32:02
Chris T writes "How do I create multiple records in a Stored Procedure from a delimited string?

i.e values from form:

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

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

--insert into year1 Table

---I need a loop here that extracts elements from string !

INSERT INTO Year1 (CourseID, Content)

VALUES (@CourseID, @year1content)

Return

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

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

Thanks in Advance.

Im using SQL Server 7 on Windows NT SP6"
   

- Advertisement -