I have the following procedure:
BEGIN TRANSACTION trKine
IF EXISTS (select * from syscolumns where id=object_id('KineTreatments') and name='KT_NNID')
INSERT INTO KinePrescriptions
(KPR_KTID, KPR_Date, KPR_DOID, KPR_NNID)
SELECT KT_ID, KT_TreatmentStart, KT_DOID, KT_NNID FROM KineTreatments
ALTER TABLE [dbo].[KineTreatments] DROP CONSTRAINT [FK_KineTreatments_Doctors]
ALTER TABLE dbo.KineTreatments DROP COLUMN KT_DOID, KT_NNID
COMMIT TRANSACTION trKine
I get the following error:
Msg 207, Level 16, State 1, Line 5
Invalid column name 'KT_NNID'.
I am absolutely sure that the column KT_NNID doesn't exist (and that the INSERT shouldn't run). Why does SSMS give me an error on this?
View Complete Post