IF EXISTS
(
    SELECT 1
    FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[AddTTACPrescription]')
          AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
    DROP PROCEDURE [dbo].[AddTTACPrescription];

IF NOT EXISTS
(
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'TTACPrescriptionDetail'
          AND COLUMN_NAME = 'NextReferDay'
)
    ALTER TABLE dbo.TTACPrescriptionDetail
    ADD NextReferDay SMALLINT NULL
            DEFAULT (0);