if I have a stored procedure say
CREATE PROCURE w AS
ALTER TABLE t ADD x char(1)
UPDATE t set x =1
Even when it lets me create that stored procedure (if I create it when x exists), when it runs, there is an error on the UPDATE statement because column x doesn't exist.
What's the conventional way to deal with this, it must come up all the time? I can work around it by putting the UPDATE inside EXEC, is there another/better way?
Thanks
ALTER TABLE in the context of 1st TRANSACTION and UPDATE in the context of 2nd:
CREATE PROCEDURE w
AS
   BEGIN TRAN
      ALTER TABLE ..
   COMMIT
   BEGIN TRAN
      UPDATE ..
   COMMIT
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With