/* 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.AccChequeInCredit
	DROP CONSTRAINT DF_AccChequeInCredit_UpdateDate
GO
ALTER TABLE dbo.AccChequeInCredit
	DROP CONSTRAINT DF_AccChequeInCredit_Updater
GO
CREATE TABLE dbo.Tmp_AccChequeInCredit
	(
	ID bigint NOT NULL IDENTITY (1, 1),
	ChequeInID 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_AccChequeInCredit ADD CONSTRAINT
	DF_AccChequeInCredit_UpdateDate DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccChequeInCredit ADD CONSTRAINT
	DF_AccChequeInCredit_Updater DEFAULT ((0)) FOR Updater
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeInCredit ON
GO
IF EXISTS(SELECT * FROM dbo.AccChequeInCredit)
	 EXEC('INSERT INTO dbo.Tmp_AccChequeInCredit (ID, ChequeInID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater)
		SELECT ID, ChequeInID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater FROM dbo.AccChequeInCredit WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeInCredit OFF
GO
DROP TABLE dbo.AccChequeInCredit
GO
EXECUTE sp_rename N'dbo.Tmp_AccChequeInCredit', N'AccChequeInCredit', 'OBJECT' 
GO
ALTER TABLE dbo.AccChequeInCredit ADD CONSTRAINT
	PK_AccChequeInCredit 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_AccChequeInCredit_ChequeID ON dbo.AccChequeInCredit
	(
	ChequeInID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
COMMIT
