IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'USERID' AND SYSOBJECTS.name = 'HMUAYENEKDGEBELIKTAKIP')
ALTER TABLE dbo.HMUAYENEKDGEBELIKTAKIP ADD
    USERID INT
GO   

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_HMUAYENEKDGEBELIK_HMUAYENEKD]') AND parent_object_id = OBJECT_ID(N'[dbo].[HMUAYENEKDGEBELIK]'))
ALTER TABLE [dbo].[HMUAYENEKDGEBELIK]  WITH NOCHECK ADD  CONSTRAINT [FK_HMUAYENEKDGEBELIK_HMUAYENEKD] FOREIGN KEY([HMUAYENEKDID])
REFERENCES [dbo].[HMUAYENEKD] ([HMUAYENEKDID])
ON UPDATE CASCADE
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_HMUAYENEKDGEBELIK_HMUAYENEKD]') AND parent_object_id = OBJECT_ID(N'[dbo].[HMUAYENEKDGEBELIK]'))
ALTER TABLE [dbo].[HMUAYENEKDGEBELIK] CHECK CONSTRAINT [FK_HMUAYENEKDGEBELIK_HMUAYENEKD]
GO

IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'BILGIALINANADISOYADI' AND SYSOBJECTS.name = 'HMUAYENEKDGEBELIKTAKIP')
ALTER TABLE dbo.HMUAYENEKDGEBELIKTAKIP ADD
    BILGIALINANADISOYADI NVARCHAR(50)
GO   

IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'BILGIALINANTELEFON' AND SYSOBJECTS.name = 'HMUAYENEKDGEBELIKTAKIP')
ALTER TABLE dbo.HMUAYENEKDGEBELIKTAKIP ADD
    BILGIALINANTELEFON NVARCHAR(20)
GO
