Afternoon and Hmmmm...
I have an SP that loads a temp table (#TmpTable) with and INSERT INTO ... SELECT ...
After the table is loaded I want to Alter #TmpTable and ADD an Indentity Column as such ...
ALTER TABLE #TmpTable
ADD ID_Key [Int] IDENTITY (1, 1) NOT NULL
Problem is ... The table never gets altered, ie column is not added, and reference to the column later in the SP fails because it does not exist.
After it fails I can select on the temp table and see all of the columns defined EXCEPT the ID that is created w/ the Alter table command.
In Query Analyzer, I can highlight the alter table command, fire it off, select the table and SEE the field now defined at the end of the temp table.
I can even add a GO right after the Alter Table statement in the SP BUT ... if you try to save it w/ the GO in this position, all of the code below the GO for the SP is dropped as expected.
WHAT AM I MISSING and how do I correct this. Not having much luck w/ turning the IDENTITY_INSERT on and off either.
Thanks ALL ...
Thanks
J. Kusch
I have an SP that loads a temp table (#TmpTable) with and INSERT INTO ... SELECT ...
After the table is loaded I want to Alter #TmpTable and ADD an Indentity Column as such ...
ALTER TABLE #TmpTable
ADD ID_Key [Int] IDENTITY (1, 1) NOT NULL
Problem is ... The table never gets altered, ie column is not added, and reference to the column later in the SP fails because it does not exist.
After it fails I can select on the temp table and see all of the columns defined EXCEPT the ID that is created w/ the Alter table command.
In Query Analyzer, I can highlight the alter table command, fire it off, select the table and SEE the field now defined at the end of the temp table.
I can even add a GO right after the Alter Table statement in the SP BUT ... if you try to save it w/ the GO in this position, all of the code below the GO for the SP is dropped as expected.
WHAT AM I MISSING and how do I correct this. Not having much luck w/ turning the IDENTITY_INSERT on and off either.
Thanks ALL ...
Thanks
J. Kusch