
    
IF (EXISTS
(
    SELECT *
    FROM sysobjects
    WHERE name = 'TblUMDrugHavaleh'
          AND type = 'U'
)
   )
BEGIN
    DECLARE @Id INT;
    SELECT @Id = id
    FROM sysobjects
    WHERE name = 'TblUMDrugHavaleh';
    IF NOT EXISTS
    (
        SELECT *
        FROM syscolumns
        WHERE id = @Id
              AND name = 'CreatedBy'
    )
    BEGIN
        ALTER TABLE TblUMDrugHavaleh
        ADD DrugHavalehInstruction NVARCHAR(200) NULL;
        ALTER TABLE TblUMDrugHavaleh ADD CreatedBy SMALLINT NULL;
        ALTER TABLE TblUMDrugHavaleh
        ADD CreatedOn DATETIME NULL
                DEFAULT GETDATE();
    END;
END;