IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'ACIKLAMA' AND SYSOBJECTS.name = 'HYBAKIMPLANI')
ALTER TABLE dbo.HYBAKIMPLANI ADD
	ACIKLAMA nvarchar(250) NULL
GO		

IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'HEMSIRETANILARIID' AND SYSOBJECTS.name = 'HYBAKIMPLANI')
ALTER TABLE dbo.HYBAKIMPLANI ADD
	HEMSIRETANILARIID int NULL
GO	

IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'HEMSIRETANILARIISLID' AND SYSOBJECTS.name = 'HYBAKIMPLANI')
ALTER TABLE dbo.HYBAKIMPLANI ADD
	HEMSIRETANILARIISLID int NULL
GO

IF NOT EXISTS(select sysobjects.id from sysconstraints inner join sysobjects on sysobjects.id = constid where sysobjects.name = 'FK_HYBAKIMPLANI_THEMSIRETANILARI' and xtype='F')
ALTER TABLE dbo.HYBAKIMPLANI ADD CONSTRAINT
	FK_HYBAKIMPLANI_THEMSIRETANILARI FOREIGN KEY
	(
	HEMSIRETANILARIID
	) REFERENCES dbo.THEMSIRETANILARI
	(
	HEMSIRETANILARIID
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO

IF NOT EXISTS(select sysobjects.id from sysconstraints inner join sysobjects on sysobjects.id = constid where sysobjects.name = 'FK_HYBAKIMPLANI_THEMSIRETANILARIISL' and xtype='F')
ALTER TABLE dbo.HYBAKIMPLANI ADD CONSTRAINT
	FK_HYBAKIMPLANI_THEMSIRETANILARIISL FOREIGN KEY
	(
	HEMSIRETANILARIISLID
	) REFERENCES dbo.THEMSIRETANILARIISL
	(
	HEMSIRETANILARIISLID
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO