if not Exists(SELECT * FROM information_schema.tables where Table_name = 'PlanningProgram') begin create table PlanningProgram ( ID int primary key, Fc_ID int references Finance_Cycle(ID) not null, Mat_ID bigint references Matter(ID) not null, Pro_ID_VahedMali int references otherProperties(ID) not null, Taf_ID bigint references Tafsili(ID) not null, Dom_ID_Status int references domain(ID) not null, Code int not null, Title nvarchar(1000) not null, ExecutionTime int not null, -- زمان اجرا StartDate int not null, -- تاریخ شروع EndDate int not null, -- تاریخ پایان [Address] nvarchar(1000), [Description] nvarchar(1000), TarikhSabt int not null, SaatSabt smallint not null, CodeKarbar int references Karbar(ID) not null, ) end go IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Bargeh' AND COLUMN_NAME = 'PP_ID') begin alter table Bargeh add PP_ID int references PlanningProgram(ID) null end go IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'DaryaftPardakht' AND COLUMN_NAME = 'PP_ID') begin alter table DaryaftPardakht add PP_ID int references PlanningProgram(ID) null end go IF not EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GardesheChek' AND COLUMN_NAME = 'PP_ID') begin alter table GardesheChek add PP_ID int references PlanningProgram(ID) null end go