IF NOT EXISTS (SELECT * FROM sys.tables t 
               JOIN sys.schemas s ON t.schema_id = s.schema_id 
               WHERE s.name = 'EHR' AND t.name = 'T_EHR_RUS_UVUJ3PNOPM')
BEGIN

-- Tables

/***** Object:  Table [EHR].[T_EHR_RUS_UVUJ3PNOPM] *****/
CREATE TABLE [EHR].[T_EHR_RUS_UVUJ3PNOPM]
(
    [EhrRusID] int NOT NULL,
    [IdEHR] int NULL,
    [NameEHR] varchar(2048) NULL,
    [EhrRusRefBooks] int NOT NULL
)
ON [PRIMARY]

-- Alters

ALTER TABLE [EHR].[T_EHR_RUS_UVUJ3PNOPM] ADD CONSTRAINT [PK_T_EHR_RUS_UVUJ3PNOPM]
PRIMARY KEY CLUSTERED ([EhrRusID]) ON [PRIMARY]

ALTER TABLE [EHR].[T_EHR_RUS_UVUJ3PNOPM] ADD CONSTRAINT [FK_T_EHR_RUS_REF_BOOKS_T_EHR_RUS_UVUJ3PNOPM_EhrRusRefBooks]
FOREIGN KEY([EhrRusRefBooks]) REFERENCES [EHR].[T_EHR_RUS_REF_BOOKS] ([EhrRusRefBooksID])

END
GO