I have a table with existing data. I have a requirement to add a new column to the table which will be populated with a value retrieved using a stored procedure. This is fine for new data I will be adding to the table.
How can I run the stored procedure for each existing row, passing in the parameters from two existing columns, and then updating the new column with the result. Effectively I want to run something like the following:
UPDATE
TableWithNewColumn
SET
NewColumn = EXEC NewProcedure(TableWithNewColumn.ID, TableWithNewColumn.Code);
See fiddle here: http://www.sqlfiddle.com/#!3/b0625/1
I know a scalar function would be ideal for this task but unfortunately the SP has been provided by a third party and it's the only way I can provide the data.