Jump to content

Sql Query Or Stored Procedure


smart190
 Share

Recommended Posts

Hi,I need some help to bulid stored procedure or some query that can read from table column some text (where separator is example ",") and put it some other table rows.For example:create table #test(line varchar(100))insert into #test(line) values ('test1, test2, test3')now is result like this: line1 test1, test2, test3what i need is that word will be in different rows: line1 test12 test23 test3

Link to comment
Share on other sites

Check the manual for whatever database you're using, check the string functions and things like that. You should be able to use a split or explode function to get the parts and loop through them. If the database doesn't have a split or explode, you'll need to do that yourself. That would involve using a function to find the position of a character (the comma), and then a substring function to get the part of the string you're interested in. MySQL has the INSTR function to find the position of a substring, and the SUBSTR or SUBSTRING functions to get part of the string.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...