-- Tables

-- Alters

ALTER TABLE [EHR].[T_EHR_RUS_REF_BOOKS] ADD [Deleted] bit NOT NULL CONSTRAINT [df_Deleted] DEFAULT 0 WITH VALUES
GO
ALTER TABLE [EHR].[T_EHR_RUS_REF_BOOKS] DROP CONSTRAINT [df_Deleted]
GO

if(exists(select * 
					from sys.columns c
					join sys.tables t on t.name = 'T_EHR_RUS_REF_BOOKS' and c.object_id = t.object_id
					where c.name = 'Del'))
begin
declare @sql varchar(max) = '
update rb
set rb.Deleted = rb.Del
from EHR.T_EHR_RUS_REF_BOOKS rb

Alter table EHR.T_EHR_RUS_REF_BOOKS drop column Del
'
exec (@sql)
end