ALTER TABLE [PHARM].[T_C_MNN] ADD [IsDrug] bit NOT NULL CONSTRAINT [df_IsDrug] DEFAULT 0 WITH VALUES
GO
ALTER TABLE [PHARM].[T_C_MNN] DROP CONSTRAINT [df_IsDrug]
GO

update mnn
set mnn.IsDrug = 1
from PHARM.T_C_MNN mnn
where exists( select top 1 IsDrug from PHARM.T_C_TRN trn where trn.CMnn = mnn.CMnnID and trn.IsDrug = 1 ) 


exec dbo.sp_AlterDropColumn 'PHARM.T_C_TRN' , 'IsDrug', 0
