USE MainDatabase

if not exists(select * from dbo.sysobjects where id = object_id(N'[dbo].[invPredprs]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[invPredprs] (
	[unn] [varchar] (20) COLLATE SQL_Latin1_General_CP1251_CI_AS NOT NULL ,
	[dopUnn] [int] NOT NULL ,
	[newDopUnn] [int] NOT NULL 
) ON [PRIMARY]

ALTER TABLE [dbo].[invPredprs] ADD 
	CONSTRAINT [PK_invPredprs] PRIMARY KEY  CLUSTERED 
	(
		[unn],
		[dopUnn]
	)  ON [PRIMARY] 
END

GO

if not exists(SELECT * FROM syscolumns WHERE (name = 'blankCode') AND (id = OBJECT_ID(N'[dbo].[DocCaption]')))
ALTER TABLE dbo.DocCaption ADD [blankCode] [varchar](10)

GO

USE Buh

if not exists(SELECT * FROM syscolumns WHERE (name = 'blankCode') AND (id = OBJECT_ID(N'[dbo].[tbTovOt]')))
ALTER TABLE dbo.tbTovOt ADD [blankCode] [varchar](10)

GO
