?
Solved

How do i unconcatenate a string in SQL?

Posted on 2006-06-11
4
Medium Priority
?
676 Views
Last Modified: 2008-02-07
I have a string such as:

322,992,124,643,233

being passed from an ASP form to a ms sql stored procedure.  i want too pull out each number and insert them into the same column, but different rows

322
992
124
643
233

How can i do this?  THanks
0
Comment
Question by:bdietz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
pootle_flump earned 1500 total points
ID: 16882107
Hi

There are more functions and methods than you could ever need here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

I think I use a version of the first one (the table returning function) as I recall. Very easy to use.

HTH
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 16882115
To be more complete - you could use the first function like this:

INSERT INTO MyTable (MyField)
SELECT      Data
FROM dbo.Split('322,992,124,643,233', ',')

HTH
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16882667
Hi bdietz,

another option is to use dynamic sql

EXEC('Insert into urTable (UrColumn)  SELECT  '+@AboveString +'')
 

Aneesh R!
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16883133
I would also use the function suggested by pootle_flump, as it protects against sql injection, and is more readable also.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
What we learned in Webroot's webinar on multi-vector protection.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question