
/* 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.AccPersonInfoTemp
	DROP CONSTRAINT DF__AccPersonI__Type__52442E1F
GO
ALTER TABLE dbo.AccPersonInfoTemp
	DROP CONSTRAINT DF__AccPerson__Updat__53385258
GO
ALTER TABLE dbo.AccPersonInfoTemp
	DROP CONSTRAINT DF__AccPerson__Updat__542C7691
GO
CREATE TABLE dbo.Tmp_AccPersonInfoTemp
	(
	ID bigint NOT NULL,
	Type tinyint NOT NULL,
	AccID bigint NOT NULL,
	Address nvarchar(250) NULL,
	Tel1 nvarchar(250) NULL,
	Tel2 nvarchar(250) NULL,
	Mobile nvarchar(250) NULL,
	Fax nvarchar(250) NULL,
	Email nvarchar(250) NULL,
	MaxCredit decimal(19, 2) NULL,
	Description nvarchar(2000) NULL,
	FinancialCode nchar(20) NULL,
	UpdateDate datetime NULL,
	Updater bigint NULL,
	Web char(100) NULL,
	MelliID char(20) NULL,
	Name nvarchar(50) NULL,
	Code char(10) NULL,
	Country bigint NULL,
	City bigint NULL,
	InIran bit NULL,
	RealOrCompany bit NULL,
	CompanyType int NULL,
	GroupType int NULL,
	OtherGroupType bigint NULL,
	VizitorTotalID bigint NULL,
	VizitorControlID bigint NULL,
	VizitorDetailID1 bigint NULL,
	VizitorDetailID2 bigint NULL,
	CodePosti char(10) NULL,
	CodeSabt char(20) NULL,
	VizitorPercent float(53) NULL,
	DiscontPercent float(53) NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_AccPersonInfoTemp ADD CONSTRAINT
	DF__AccPersonI__Type__52442E1F DEFAULT ((0)) FOR Type
GO
ALTER TABLE dbo.Tmp_AccPersonInfoTemp ADD CONSTRAINT
	DF__AccPerson__Updat__53385258 DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccPersonInfoTemp ADD CONSTRAINT
	DF__AccPerson__Updat__542C7691 DEFAULT ((0)) FOR Updater
GO
IF EXISTS(SELECT * FROM dbo.AccPersonInfoTemp)
	 EXEC('INSERT INTO dbo.Tmp_AccPersonInfoTemp (ID, Type, AccID, Address, Tel1, Tel2, Mobile, Fax, Email, MaxCredit, Description, FinancialCode, UpdateDate, Updater, Web, MelliID, Name, Code, Country, City, InIran, RealOrCompany, CompanyType, GroupType, OtherGroupType, VizitorTotalID, VizitorControlID, VizitorDetailID1, VizitorDetailID2, CodePosti, CodeSabt, VizitorPercent, DiscontPercent)
		SELECT ID, Type, AccID, Address, CONVERT(nvarchar(250), Tel1), CONVERT(nvarchar(250), Tel2), CONVERT(nvarchar(250), Mobile), CONVERT(nvarchar(250), Fax), CONVERT(nvarchar(250), Email), MaxCredit, Description, FinancialCode, UpdateDate, Updater, Web, MelliID, Name, Code, Country, City, InIran, RealOrCompany, CompanyType, GroupType, OtherGroupType, VizitorTotalID, VizitorControlID, VizitorDetailID1, VizitorDetailID2, CodePosti, CodeSabt, VizitorPercent, DiscontPercent FROM dbo.AccPersonInfoTemp WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.AccPersonInfoTemp
GO
EXECUTE sp_rename N'dbo.Tmp_AccPersonInfoTemp', N'AccPersonInfoTemp', 'OBJECT' 
GO
create      TRIGGER dbo.AccPersonInfoTemp_Update ON dbo.AccPersonInfoTemp instead of UPDATE 
	AS

  	return
GO
create      TRIGGER dbo.AccPersonInfoTemp_Delete ON dbo.AccPersonInfoTemp instead of DELETE 
	AS
		
	return
GO
COMMIT
