bdietz
asked on
How do i unconcatenate a string in SQL?
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi bdietz,
another option is to use dynamic sql
EXEC('Insert into urTable (UrColumn) SELECT '+@AboveString +'')
Aneesh R!
another option is to use dynamic sql
EXEC('Insert into urTable (UrColumn) SELECT '+@AboveString +'')
Aneesh R!
I would also use the function suggested by pootle_flump, as it protects against sql injection, and is more readable also.
INSERT INTO MyTable (MyField)
SELECT Data
FROM dbo.Split('322,992,124,643
HTH