/* 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.AccChequeInOwner
	DROP CONSTRAINT DF_AccChequeInOwner_UpdateDate
GO
ALTER TABLE dbo.AccChequeInOwner
	DROP CONSTRAINT DF_AccChequeInOwner_Updater
GO
CREATE TABLE dbo.Tmp_AccChequeInOwner
	(
	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_AccChequeInOwner ADD CONSTRAINT
	DF_AccChequeInOwner_UpdateDate DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccChequeInOwner ADD CONSTRAINT
	DF_AccChequeInOwner_Updater DEFAULT ((0)) FOR Updater
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeInOwner ON
GO
IF EXISTS(SELECT * FROM dbo.AccChequeInOwner)
	 EXEC('INSERT INTO dbo.Tmp_AccChequeInOwner (ID, ChequeInID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater)
		SELECT ID, ChequeInID, TotalID, ControlID, DetailID1, DetailID2, ChequeValue, ChequePercent, UpdateDate, Updater FROM dbo.AccChequeInOwner WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_AccChequeInOwner OFF
GO
DROP TABLE dbo.AccChequeInOwner
GO
EXECUTE sp_rename N'dbo.Tmp_AccChequeInOwner', N'AccChequeInOwner', 'OBJECT' 
GO
ALTER TABLE dbo.AccChequeInOwner ADD CONSTRAINT
	PK_AccChequeInOwner 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_AccChequeInOwner_ChequeID ON dbo.AccChequeInOwner
	(
	ChequeInID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
COMMIT
