sql - Alter table add field then error whilst using it -


i trying add field table. if create table , call sp , add field inside sp. cannot use field in clause

  1. run part 1 , part 2 together: no error
  2. run part 1 part 2 inside sp: error (dont forget drop #table when done)
  3. run part 1 part two: error (dont forget drop #table when done)

example:

/*part 1*/ select 1 number #table union  select 2 number /*******/  /*part 2*/ alter table #table add rowno int identity(1,1);  select * #table rowno between 0 , 10  drop table #table /********/ 

here mean run in stored proc (new sql fiddle):

http://sqlfiddle.com/#!3/545ff/1

it seems error thrown during code compilation. if run select (or other queries directly reference new column) inside exec() command, works:

http://sqlfiddle.com/#!3/76b8c/1


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -