TSQL - MSSQL 2008 add a column and update it in same stored procedure
Posted
by TortTupper
on Stack Overflow
See other posts from Stack Overflow
or by TortTupper
Published on 2010-06-09T11:08:16Z
Indexed on
2010/06/09
11:12 UTC
Read the original article
Hit count: 119
tsql
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
© Stack Overflow or respective owner