Sorry for the incorrect wording of the question. I was not sure how to describe it. I want to iterate over each row of the table and at the same time retrieve the column, analyze the varchar located in it and depending on what it finds, inserts the rows into another table. Something like that:
DECLARE @string varchar(max); foreach row in (select * from Table) { set @string = row[column]; while (len(@string) > 0) { -- Do all the parsing in here if (found what was looking for) insert into Table2 values(row[column2], row[column3]); } }
It would be very nice if it were a stored procedure, so you need to do this in SQL. I'm just not too sure how to approach him. Thanks.
Edit:
This is basically the functionality I was hoping for:
Table 1 | id_number | text | 1 Hello, test 532. Yay oh and test 111 2 test 932. 3 This is a test 315 of stuff test 555. 4 haflksdhfal test 311 sadjhfalsd 5 Yay.
I want to go through this table and analyze all the text columns to look for instances of "test #", where # is a number. When he finds something inside the text in this format, he inserts this value into another table, for example:
Table 2 | id_number | number 1 532 1 111 2 932 3 315 3 555 4 311
source share