Use BUH
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbSFSverka]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

begin

CREATE TABLE [dbo].[tbSFSverka] (
	[IdSFSverka] [int] IDENTITY (1, 1) NOT NULL ,
	[Prizn] [bit] NULL ,
	[IdSchetSubSchetDt] [int] NULL ,
	[IdSchetSubSchetKt] [int] NULL 
) ON [PRIMARY]


ALTER TABLE [dbo].[tbSFSverka] ADD 
	CONSTRAINT [PK_tbSFSverka] PRIMARY KEY  CLUSTERED 
	(
		[IdSFSverka]
	)  ON [PRIMARY] 
end
GO

if not Exists(Select c.id from SysColumns c inner join SysObjects o on c.Id=o.Id
      where c.Name='Sv' and o.Name='tbTovOt') 
ALTER TABLE dbo.tbTovOt ADD
	Sv bit NOT NULL DEFAULT(0)
GO

if not Exists(Select c.id from SysColumns c inner join SysObjects o on c.Id=o.Id
      where c.Name='Sv' and o.Name='tbSpravka') 
ALTER TABLE dbo.tbSpravka  ADD
	Sv bit NOT NULL DEFAULT(0)
GO

if not Exists(Select c.id from SysColumns c inner join SysObjects o on c.Id=o.Id
      where c.Name='IdNameUsl' and o.Name='tbSpravka') 

ALTER TABLE dbo.tbSpravka ADD
	IdNameUsl int NULL
GO

Use MainDataBase

if not Exists(Select c.id from SysColumns c inner join SysObjects o on c.Id=o.Id
      where c.Name='Sv' and o.Name='invoices') 
ALTER TABLE dbo.invoices ADD
	Sv bit NOT NULL DEFAULT(0)
GO
