I have a table which has an nvarchar column. The strings stored in this nvarchar column contain numbers which I need to extract. There is a table-valued RegexMatches function existing in my database that I can use to do this (it’ll return a list of matches for the number pattern).
My Requirement:
This table-valued function has to be applied to this column in each row of the table. I cannot store the intermediate results anywhere (meaning function to row 1 – store – apply function to row 2 – store) because I don’t know how many records will be there and there may well be 100s. At the end of the procedure, I should have a temporary table where all these numbers extracted from all rows are stored.
You want to use CROSS APPLY. See further example here.