DECLARE @Name AS NVARCHAR(MAX);
IF (EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'TmpDrugH'
          AND COLUMN_NAME = 'FamilyDoctorCode'
)
   )
BEGIN
    SELECT @Name = O.name
    FROM sys.columns C
        JOIN sys.objects O
            ON O.object_id = C.default_object_id
    WHERE C.object_id = OBJECT_ID('TmpDrugH')
          AND C.name = 'FamilyDoctorCode';
    IF @Name IS NOT NULL
        EXEC ('ALTER TABLE dbo.tmpDrugH DROP CONSTRAINT ' + @Name);
    ALTER TABLE dbo.TmpDrugH ALTER COLUMN FamilyDoctorCode DEC(18, 0);

    ALTER TABLE dbo.TmpDrugH
    ADD CONSTRAINT DF_TMP_FamilyDoctorCode
        DEFAULT 0 FOR FamilyDoctorCode;
END;
ELSE
    ALTER TABLE dbo.TmpDrugH ADD FamilyDoctorCode DEC(18, 0) DEFAULT (0);

SET @Name = N'';

IF (EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'DrugH'
          AND COLUMN_NAME = 'FamilyDoctorCode'
)
   )
BEGIN
    SELECT @Name = O.name
    FROM sys.columns C
        JOIN sys.objects O
            ON O.object_id = C.default_object_id
    WHERE C.object_id = OBJECT_ID('DrugH')
          AND C.name = 'FamilyDoctorCode';
    IF @Name IS NOT NULL
        EXEC ('ALTER TABLE dbo.DrugH DROP CONSTRAINT ' + @Name);
    ALTER TABLE dbo.DrugH ALTER COLUMN FamilyDoctorCode DEC(18, 0);

    ALTER TABLE dbo.DrugH
    ADD CONSTRAINT DF_DrugH_FamilyDoctorCode
        DEFAULT 0 FOR FamilyDoctorCode;
END;
ELSE
    ALTER TABLE dbo.DrugH ADD FamilyDoctorCode DEC(18, 0) DEFAULT (0);

IF NOT EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'TAMINPrescriptionDetail'
          AND COLUMN_NAME = 'IsIncludeSupplementaryInsurance'
)
    ALTER TABLE dbo.TaminPrescriptionDetail
    ADD [IsIncludeSupplementaryInsurance] BIT NULL
            DEFAULT (1);


IF NOT EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'IHIOPrescriptionDetail'
          AND COLUMN_NAME = 'IsIncludeSupplementaryInsurance'
)
    ALTER TABLE dbo.IHIOPrescriptionDetail
    ADD [IsIncludeSupplementaryInsurance] BIT NULL
            DEFAULT (1);


IF NOT EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'TTACPrescriptionDetail'
          AND COLUMN_NAME = 'IsIncludeSupplementaryInsurance'
)
    ALTER TABLE dbo.TTACPrescriptionDetail
    ADD [IsIncludeSupplementaryInsurance] BIT NULL
            DEFAULT (1);