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
- run part 1 , part 2 together: no error
- run part 1 part 2 inside sp: error (dont forget drop #table when done)
- 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):
it seems error thrown during code compilation. if run select (or other queries directly reference new column) inside exec() command, works:
Comments
Post a Comment