I need to add an additional column to an existing table, and afterwards insert the appropriate column values for the existing records. I need to do this within a single stored procedure.
So far I have the following (SQL Management studio reports that it cannot find the new column in order to add the values to the existing records):
BEGIN
ALTER TABLE tbl1
ADD col_add int
UPDATE tbl1
SET [col_add]='value'
WHERE col_pk = 1
END
I have tried adding a "GO" keyword between the ALTER and UPDATE statements, but then it reports a syntax error.
Thanks in advance.