title: Add a column and update it in same stored procedure in SQL Server 2008
body: <p>if I have a stored procedure say</p>
  
  <pre><code>CREATE PROCURE w AS
  
  ALTER TABLE t ADD x char(1)
  
  UPDATE t set x =1
  </code></pre>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>Thanks</p>