I am having a problem with the T-SQL parser when creating a stored proc.
The issue is that my stored proc adds a new field to a table and then updates the field. The parser fails due to the field not existing at the moment. Is there any way to bodge this to make the stored proc save.
Here is the example: (I have removed all comments, error handling, etc)
CREATE PROCEDURE dbo.DW2_tblAddress AS
ALTER TABLE imp_tblAddress ADD LookupPostCode char(8) NULL
update imp_tblAddress set LookupPostCode = 'ABC'
return(0)
GO
Gives me the error:
Server: Msg 207, Level 16, State 1, Procedure DW2_tblAddress, Line 57
Invalid column name 'LookupPostCode'.
The issue is that my stored proc adds a new field to a table and then updates the field. The parser fails due to the field not existing at the moment. Is there any way to bodge this to make the stored proc save.
Here is the example: (I have removed all comments, error handling, etc)
CREATE PROCEDURE dbo.DW2_tblAddress AS
ALTER TABLE imp_tblAddress ADD LookupPostCode char(8) NULL
update imp_tblAddress set LookupPostCode = 'ABC'
return(0)
GO
Gives me the error:
Server: Msg 207, Level 16, State 1, Procedure DW2_tblAddress, Line 57
Invalid column name 'LookupPostCode'.