
/* 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.AccChequeOutDebit
	DROP CONSTRAINT DF_AccChequeOutDebit_UpdateDate
GO
ALTER TABLE dbo.AccChequeOutDebit
	DROP CONSTRAINT DF_AccChequeOutDebit_Updater
GO
CREATE TABLE dbo.Tmp_AccChequeOutDebit
	(
	ID bigint NOT NULL IDENTITY (1, 1),
	ChequeOutID bigint NOT NULL,
	TotalID bigint NOT NULL,
	ControlID bigint NOT NULL,
	DetailID1 bigint NOT NULL,
	DetailID2 bigint NOT NULL,
	ChequeValue decimal(28, 5) NOT NULL,
	ChequePercent int NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NOT NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_AccChequeOutDebit ADD CONSTRAINT
	DF_AccChequeOutDebit_UpdateDate DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccChequeOutDebit ADD CONSTRAINT
	DF_AccChequeOutDebit_Updater DEFAULT ((0)) FOR Updater
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeOutDebit ON
GO
IF EXISTS(SELECT * FROM dbo.AccChequeOutDebit)
	 EXEC('INSERT INTO dbo.Tmp_AccChequeOutDebit (ID, ChequeOutID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater)
		SELECT ID, ChequeOutID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater FROM dbo.AccChequeOutDebit WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeOutDebit OFF
GO
DROP TABLE dbo.AccChequeOutDebit
GO
EXECUTE sp_rename N'dbo.Tmp_AccChequeOutDebit', N'AccChequeOutDebit', 'OBJECT' 
GO
ALTER TABLE dbo.AccChequeOutDebit ADD CONSTRAINT
	PK_AccChequeOutDebit PRIMARY KEY CLUSTERED 
	(
	ID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
CREATE NONCLUSTERED INDEX IX_AccChequeOutDebit_ChequeID ON dbo.AccChequeOutDebit
	(
	ChequeOutID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
COMMIT
