/* 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_TaxFactorHeader
	(
	MyID bigint NOT NULL IDENTITY (1, 1),
	ID bigint NOT NULL,
	Number bigint NOT NULL,
	UserNumber bigint NOT NULL,
	Taxid char(22) NOT NULL,
	Date datetime NOT NULL,
	DatePer char(12) NOT NULL,
	Indatim bigint NOT NULL,
	CreateDate datetime NOT NULL,
	CreateDatePer char(12) NOT NULL,
	Indati2m bigint NOT NULL,
	Inty int NOT NULL,
	Inno char(10) NOT NULL,
	Irtaxid char(22) NOT NULL,
	Inp int NOT NULL,
	Ins int NOT NULL,
	Tins char(14) NOT NULL,
	Description nvarchar(2000) NOT NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NOT NULL,
	Tob int NOT NULL,
	Bid char(22) NOT NULL,
	Tinb char(22) NOT NULL,
	Sbc char(22) NOT NULL,
	Bpc char(12) NOT NULL,
	Bbc char(22) NOT NULL,
	Ft int NOT NULL,
	Bpn char(50) NOT NULL,
	Scln char(12) NOT NULL,
	Scc char(12) NOT NULL,
	Crn char(12) NOT NULL,
	Billid char(12) NOT NULL,
	PersonTitle nvarchar(500) NOT NULL,
	TprdisTotalPrice decimal(18, 0) NOT NULL,
	TdisDiscont decimal(18, 0) NOT NULL,
	Tadis decimal(18, 0) NOT NULL,
	TvamMaliatAfzodeh decimal(18, 0) NOT NULL,
	TodamSayerMaliat decimal(18, 0) NOT NULL,
	TbillPaid decimal(18, 0) NOT NULL,
	Setm int NOT NULL,
	CapNaghdi decimal(18, 0) NOT NULL,
	InspNesieh decimal(18, 0) NOT NULL,
	TvopPaiedTax decimal(18, 0) NOT NULL,
	Tax17 decimal(18, 0) NOT NULL,
	Cdcn char(22) NOT NULL,
	Cdcd int NOT NULL,
	Tonw decimal(18, 0) NOT NULL,
	Torv decimal(18, 0) NOT NULL,
	Tocv decimal(18, 0) NOT NULL,
	UID uniqueidentifier NOT NULL,
	ReferenceNumber nvarchar(100) NOT NULL,
	InsertDate datetime NOT NULL,
	Inserter bigint NOT NULL
	)  ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_TaxFactorHeader ON
GO
IF EXISTS(SELECT * FROM dbo.TaxFactorHeader)
	 EXEC('INSERT INTO dbo.Tmp_TaxFactorHeader (MyID, ID, Number, UserNumber, Taxid, Date, DatePer, Indatim, CreateDate, CreateDatePer, Indati2m, Inty, Inno, Irtaxid, Inp, Ins, Tins, Description, UpdateDate, Updater, Tob, Bid, Tinb, Sbc, Bpc, Bbc, Ft, Bpn, Scln, Scc, Crn, Billid, PersonTitle, TprdisTotalPrice, TdisDiscont, Tadis, TvamMaliatAfzodeh, TodamSayerMaliat, TbillPaid, Setm, CapNaghdi, InspNesieh, TvopPaiedTax, Tax17, Cdcn, Cdcd, Tonw, Torv, Tocv, UID, ReferenceNumber, InsertDate, Inserter)
		SELECT MyID, ID, Number, UserNumber, Taxid, Date, DatePer, Indatim, CreateDate, CreateDatePer, Indati2m, Inty, Inno, Irtaxid, Inp, Ins, Tins, Description, UpdateDate, Updater, Tob, Bid, Tinb, Sbc, Bpc, Bbc, Ft, Bpn, Scln, Scc, Crn, Billid, PersonTitle, TprdisTotalPrice, TdisDiscont, Tadis, TvamMaliatAfzodeh, TodamSayerMaliat, TbillPaid, Setm, CapNaghdi, InspNesieh, TvopPaiedTax, Tax17, Cdcn, Cdcd, Tonw, Torv, Tocv, UID, CONVERT(nvarchar(100), ReferenceNumber), InsertDate, Inserter FROM dbo.TaxFactorHeader WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_TaxFactorHeader OFF
GO
DROP TABLE dbo.TaxFactorHeader
GO
EXECUTE sp_rename N'dbo.Tmp_TaxFactorHeader', N'TaxFactorHeader', 'OBJECT' 
GO
ALTER TABLE dbo.TaxFactorHeader ADD CONSTRAINT
	PK_TaxFactorHeader PRIMARY KEY CLUSTERED 
	(
	MyID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT
