USE MainDataBase

INSERT INTO invoices
SELECT * FROM tempInvoices
GO

INSERT INTO documents
SELECT * FROM tempDocuments
GO

INSERT INTO consignees
SELECT * FROM tempConsignees
GO

INSERT INTO consignors
SELECT * FROM tempConsignors
GO

INSERT INTO roster
SELECT idSender, compilingYear, number, pnt, itemNumber, [name], code, code_oced,
units, [count], price, cost, summaExcise, rate, idRateType, summaVat, costVat
FROM tempRoster
GO

INSERT INTO descriptions
SELECT * FROM tempDescriptions
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempInvoices]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempInvoices]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempDocuments]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempDocuments]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempConsignees]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempConsignees]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempConsignors]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempConsignors]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempRoster]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempRoster]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempDescriptions]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tempDescriptions]
GO