BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Tmp_AccFactorTemp
	(
	ID bigint NOT NULL,
	Type smallint NULL,
	Number bigint NOT NULL,
	UserNumber bigint NOT NULL,
	Date datetime NOT NULL,
	SeriallID bigint NOT NULL,
	PersonTotalID bigint NOT NULL,
	PersonControlID bigint NOT NULL,
	PersonDetailID1 bigint NOT NULL,
	PersonDetailID2 bigint NOT NULL,
	PersonAddress nvarchar(500) NULL,
	PersonFinancialCode nchar(20) NULL,
	PersonTel nvarchar(250) NULL,
	PersonFax nvarchar(250) NULL,
	PersonEmail nvarchar(250) NULL,
	PersonWeb nvarchar(250) NULL,
	Description nvarchar(2000) NULL,
	Discont decimal(28, 5) NOT NULL,
	DiscontIsPercent bit NOT NULL,
	PayType bit NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NOT NULL,
	DiscontTotalID bigint NULL,
	DiscontControlID bigint NULL,
	DiscontDetailID1 bigint NULL,
	DiscontDetailID2 bigint NULL,
	WarehouseID bigint NULL,
	WareOutID bigint NULL,
	FromWarehouse bit NULL,
	Avarez decimal(28, 5) NULL,
	AvarezIsPercent bit NULL,
	AvarezTotalID bigint NULL,
	AvarezControlID bigint NULL,
	AvarezDetailID1 bigint NULL,
	AvarezDetailID2 bigint NULL,
	Haml decimal(28, 5) NULL,
	HamlIsPercent bit NULL,
	HamlTotalID bigint NULL,
	HamlControlID bigint NULL,
	HamlDetailID1 bigint NULL,
	HamlDetailID2 bigint NULL,
	PayTime int NULL,
	Paid bit NULL,
	IsPermanent bit NULL,
	VizitorTotalID bigint NULL,
	VizitorControlID bigint NULL,
	VizitorDetailID1 bigint NULL,
	VizitorDetailID2 bigint NULL,
	SellType int NULL,
	PersonCodePosti nchar(15) NULL,
	PersonSabt nchar(20) NULL,
	PersonShenase nchar(20) NULL,
	CostCenter bigint NULL,
	Project bigint NULL,
	OrderID bigint NULL,
	IsFalsi bit NOT NULL,
	Zir5Darsad bit NOT NULL,
	HaghAmalKari bit NOT NULL,
	Type1Code int NULL,
	CityCode char(7) NULL,
	KalaTypeID int NULL,
	PrePayment decimal(28, 5) NULL,
	UID uniqueidentifier NULL,
	TaxUID nvarchar(100) NULL,
	TaxType int NULL,
	TaxIns int NOT NULL,
	Taxid char(22) NULL,
	Irtaxid char(22) NULL,
	IrID bigint NULL,
	Scc bigint NULL,
	Cdcn nvarchar(20) NULL,
	Cdcd datetime NULL,
	Cut char(3) NULL,
	Exr decimal(28, 5) NULL,
	DeleteDate datetime NOT NULL
	)  ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.AccFactorTemp)
	 EXEC('INSERT INTO dbo.Tmp_AccFactorTemp (ID, Type, Number, UserNumber, Date, SeriallID, PersonTotalID, PersonControlID, PersonDetailID1, PersonDetailID2, PersonAddress, PersonFinancialCode, PersonTel, PersonFax, PersonEmail, PersonWeb, Description, Discont, DiscontIsPercent, PayType, UpdateDate, Updater, DiscontTotalID, DiscontControlID, DiscontDetailID1, DiscontDetailID2, WarehouseID, WareOutID, FromWarehouse, Avarez, AvarezIsPercent, AvarezTotalID, AvarezControlID, AvarezDetailID1, AvarezDetailID2, Haml, HamlIsPercent, HamlTotalID, HamlControlID, HamlDetailID1, HamlDetailID2, PayTime, Paid, IsPermanent, VizitorTotalID, VizitorControlID, VizitorDetailID1, VizitorDetailID2, SellType, PersonCodePosti, PersonSabt, PersonShenase, CostCenter, Project, OrderID, IsFalsi, Zir5Darsad, HaghAmalKari, Type1Code, CityCode, KalaTypeID, PrePayment, UID, TaxUID, TaxType, TaxIns, Taxid, Irtaxid, IrID, Scc, Cdcn, Cdcd, Cut, Exr, DeleteDate)
		SELECT ID, Type, Number, UserNumber, Date, SeriallID, PersonTotalID, PersonControlID, PersonDetailID1, PersonDetailID2, PersonAddress, PersonFinancialCode, PersonTel, PersonFax, PersonEmail, PersonWeb, Description, Discont, DiscontIsPercent, PayType, UpdateDate, Updater, DiscontTotalID, DiscontControlID, DiscontDetailID1, DiscontDetailID2, WarehouseID, WareOutID, FromWarehouse, Avarez, AvarezIsPercent, AvarezTotalID, AvarezControlID, AvarezDetailID1, AvarezDetailID2, Haml, HamlIsPercent, HamlTotalID, HamlControlID, HamlDetailID1, HamlDetailID2, PayTime, Paid, IsPermanent, VizitorTotalID, VizitorControlID, VizitorDetailID1, VizitorDetailID2, SellType, CONVERT(nchar(15), PersonCodePosti), CONVERT(nchar(20), PersonSabt), CONVERT(nchar(20), PersonShenase), CostCenter, Project, OrderID, IsFalsi, Zir5Darsad, HaghAmalKari, Type1Code, CityCode, KalaTypeID, PrePayment, UID, TaxUID, TaxType, TaxIns, Taxid, Irtaxid, IrID, Scc, Cdcn, Cdcd, Cut, Exr, DeleteDate FROM dbo.AccFactorTemp WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.AccFactorTemp
GO
EXECUTE sp_rename N'dbo.Tmp_AccFactorTemp', N'AccFactorTemp', 'OBJECT' 
GO
COMMIT
