/* 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_TaxResults
	(
	ID bigint NOT NULL IDENTITY (1, 1),
	UID uniqueidentifier NOT NULL,
	ReferenceNumber uniqueidentifier NOT NULL,
	Status nvarchar(200) NOT NULL,
	FAILED bit NOT NULL,
	ConfirmationReferenceId uniqueidentifier NOT NULL,
	Type nvarchar(200) NOT NULL,
	code varchar(100) NOT NULL,
	msg nvarchar(2000) NOT NULL,
	detail nvarchar(MAX) NOT NULL,
	InsertDate datetime NOT NULL,
	Inserter bigint NOT NULL
	)  ON [PRIMARY]
	 TEXTIMAGE_ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_TaxResults ON
GO
IF EXISTS(SELECT * FROM dbo.TaxResults)
	 EXEC('INSERT INTO dbo.Tmp_TaxResults (ID, UID, ReferenceNumber, Status, FAILED, ConfirmationReferenceId, Type, code, msg, detail, InsertDate, Inserter)
		SELECT ID, UID, ReferenceNumber, Status, FAILED, ConfirmationReferenceId, Type, CONVERT(varchar(100), code), msg, detail, InsertDate, Inserter FROM dbo.TaxResults WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_TaxResults OFF
GO
DROP TABLE dbo.TaxResults
GO
EXECUTE sp_rename N'dbo.Tmp_TaxResults', N'TaxResults', 'OBJECT' 
GO
ALTER TABLE dbo.TaxResults ADD CONSTRAINT
	PK_TaxResults PRIMARY KEY CLUSTERED 
	(
	ID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT
