/* 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
ALTER TABLE dbo.AccWarehouseInfoTemp
	DROP CONSTRAINT DF__AccWarehou__Type__113584D1
GO
ALTER TABLE dbo.AccWarehouseInfoTemp
	DROP CONSTRAINT DF__AccWareho__Updat__1229A90A
GO
ALTER TABLE dbo.AccWarehouseInfoTemp
	DROP CONSTRAINT DF__AccWareho__Updat__131DCD43
GO
CREATE TABLE dbo.Tmp_AccWarehouseInfoTemp
	(
	ID bigint NOT NULL,
	Type int NOT NULL,
	AccID bigint NOT NULL,
	Price decimal(28, 5) NULL,
	Unit bigint NULL,
	Description nvarchar(3000) NULL,
	MinimumIn decimal(28, 5) NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NULL,
	OrderPoint decimal(28, 5) NULL,
	TotalID bigint NULL,
	ControlID bigint NULL,
	DetailID1 bigint NULL,
	DetailID2 bigint NULL,
	PriceSell decimal(28, 5) NULL,
	IranCode nchar(20) NULL,
	BarCode nvarchar(500) NULL,
	StandardCode nchar(20) NULL,
	Avarez float(53) NULL,
	WareAddress nvarchar(500) NULL,
	Oft int NULL,
	RotubatPayeh int NULL,
	RotubatFasli int NULL,
	StandardFormula bit NULL,
	UseLocallRotubatSetting bit NULL,
	Name nvarchar(50) NULL,
	Code char(20) NULL,
	Base bigint NULL,
	Pakaging bigint NULL,
	ProdType bigint NULL,
	Phisics bigint NULL,
	UnitSecondary bigint NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_AccWarehouseInfoTemp ADD CONSTRAINT
	DF__AccWarehou__Type__113584D1 DEFAULT ((0)) FOR Type
GO
ALTER TABLE dbo.Tmp_AccWarehouseInfoTemp ADD CONSTRAINT
	DF__AccWareho__Updat__1229A90A DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccWarehouseInfoTemp ADD CONSTRAINT
	DF__AccWareho__Updat__131DCD43 DEFAULT ((0)) FOR Updater
GO
IF EXISTS(SELECT * FROM dbo.AccWarehouseInfoTemp)
	 EXEC('INSERT INTO dbo.Tmp_AccWarehouseInfoTemp (ID, Type, AccID, Price, Unit, Description, MinimumIn, UpdateDate, Updater, OrderPoint, TotalID, ControlID, DetailID1, DetailID2, PriceSell, IranCode, BarCode, StandardCode, Avarez, WareAddress, Oft, RotubatPayeh, RotubatFasli, StandardFormula, UseLocallRotubatSetting, Name, Code, Base, Pakaging, ProdType, Phisics, UnitSecondary)
		SELECT ID, Type, AccID, Price, Unit, Description, MinimumIn, UpdateDate, Updater, OrderPoint, TotalID, ControlID, DetailID1, DetailID2, PriceSell, IranCode, CONVERT(nvarchar(500), BarCode), StandardCode, Avarez, WareAddress, Oft, RotubatPayeh, RotubatFasli, StandardFormula, UseLocallRotubatSetting, Name, Code, Base, Pakaging, ProdType, Phisics, UnitSecondary FROM dbo.AccWarehouseInfoTemp WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.AccWarehouseInfoTemp
GO
EXECUTE sp_rename N'dbo.Tmp_AccWarehouseInfoTemp', N'AccWarehouseInfoTemp', 'OBJECT' 
GO
create      TRIGGER dbo.AccWarehouseInfoTemp_Update ON dbo.AccWarehouseInfoTemp instead of UPDATE 
	AS

  	return
GO
create      TRIGGER dbo.AccWarehouseInfoTemp_Delete ON dbo.AccWarehouseInfoTemp instead of DELETE 
	AS
		
	return
GO
COMMIT
