Solved

How do i unconcatenate a string in SQL?

Posted on 2006-06-11
4
575 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 500 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

707 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