/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
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_AccFactorDetailTemp
	(
	ID bigint NOT NULL,
	FactorID bigint NOT NULL,
	OrderTotalID bigint NOT NULL,
	OrderControlID bigint NOT NULL,
	OrderDetailID1 bigint NOT NULL,
	OrderDetailID2 bigint NOT NULL,
	Request decimal(19, 5) NOT NULL,
	RequestUnit bigint NOT NULL,
	NetPrice decimal(19, 5) NOT NULL,
	TotalPrice decimal(28, 5) NOT NULL,
	DocItemID bigint NOT NULL,
	DocItemRelationID int NULL,
	DocHeaderID bigint NULL,
	Status int NULL,
	OtherTotalID bigint NULL,
	OtherControlID bigint NULL,
	OtherDetailID1 bigint NULL,
	OtherDetailID2 bigint NULL,
	Value2 decimal(19, 5) NULL,
	Unit2 bigint NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NOT NULL,
	Discont decimal(28, 5) NULL,
	Maliat decimal(28, 5) NULL,
	Avarez decimal(28, 5) NULL,
	Heigh decimal(18, 5) NULL,
	Lenght decimal(18, 5) NULL,
	Width decimal(18, 5) NULL,
	ZowjInUnit decimal(18, 5) NULL,
	Pakaging int NULL,
	Oft float(53) NULL,
	WarehouseNo bigint NULL,
	SumInFactor bit NULL,
	OrderID bigint NULL,
	SayerVojoh decimal(19, 5) NULL,
	Nw decimal(19, 5) NULL,
	Ssrv decimal(19, 5) NULL,
	Sscv decimal(19, 5) NULL,
	Haml decimal(28, 5) NULL,
	HamlTotalID bigint NULL,
	HamlControlID bigint NULL,
	HamlDetailID1 bigint NULL,
	HamlDetailID2 bigint NULL,
	DeleteDate datetime NOT NULL
	)  ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.AccFactorDetailTemp)
	 EXEC('INSERT INTO dbo.Tmp_AccFactorDetailTemp (ID, FactorID, OrderTotalID, OrderControlID, OrderDetailID1, OrderDetailID2, Request, RequestUnit, NetPrice, TotalPrice, DocItemID, DocItemRelationID, DocHeaderID, Status, OtherTotalID, OtherControlID, OtherDetailID1, OtherDetailID2, Value2, Unit2, UpdateDate, Updater, Discont, Maliat, Avarez, Heigh, Lenght, Width, ZowjInUnit, Pakaging, Oft, WarehouseNo, SumInFactor, OrderID, SayerVojoh, Nw, Ssrv, Sscv, DeleteDate)
		SELECT ID, FactorID, OrderTotalID, OrderControlID, OrderDetailID1, OrderDetailID2, Request, RequestUnit, NetPrice, TotalPrice, DocItemID, DocItemRelationID, DocHeaderID, Status, OtherTotalID, OtherControlID, OtherDetailID1, OtherDetailID2, Value2, Unit2, UpdateDate, Updater, Discont, Maliat, Avarez, Heigh, Lenght, Width, ZowjInUnit, Pakaging, Oft, WarehouseNo, SumInFactor, OrderID, SayerVojoh, Nw, Ssrv, Sscv, DeleteDate FROM dbo.AccFactorDetailTemp WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.AccFactorDetailTemp
GO
EXECUTE sp_rename N'dbo.Tmp_AccFactorDetailTemp', N'AccFactorDetailTemp', 'OBJECT' 
GO
COMMIT
