Use ATNDBTest
Go


/* 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.FactorCashSettlementCheckBridge
	DROP CONSTRAINT FK_FactorCashSettlementCheckBridge_CheckGetPayHeader
GO
ALTER TABLE dbo.CheckGetPayHeader SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge
	DROP CONSTRAINT FK_FactorCashSettlementCheckBridge_CashGetPay
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge
	DROP CONSTRAINT FK_FactorCashSettlementCheckBridge_SettlementGetPay
GO
ALTER TABLE dbo.CashGetPay SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge
	DROP CONSTRAINT FK_FactorCashSettlementCheckBridge_GritFactor
GO
ALTER TABLE dbo.GritFactor SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge
	DROP CONSTRAINT FK_FactorCashSettlementCheckBridge_FactorHeader
GO
ALTER TABLE dbo.FactorHeader SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Tmp_FactorCashSettlementCheckBridge
	(
	Serial bigint NOT NULL,
	FactorHeaderRef bigint NULL,
	GritFactorRef bigint NULL,
	CashGetPayRef bigint NULL,
	CashGetPayAmount bigint NULL,
	SettlementGetPayRef bigint NULL,
	SettlementGetPayAmount bigint NULL,
	CheckGetPayHeaderRef bigint NULL,
	CheckGetPayAmount bigint NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_FactorCashSettlementCheckBridge SET (LOCK_ESCALATION = TABLE)
GO
IF EXISTS(SELECT * FROM dbo.FactorCashSettlementCheckBridge)
	 EXEC('INSERT INTO dbo.Tmp_FactorCashSettlementCheckBridge (Serial, FactorHeaderRef, GritFactorRef, CashGetPayRef, SettlementGetPayRef, CheckGetPayHeaderRef)
		SELECT Serial, FactorHeaderRef, GritFactorRef, CashGetPayRef, SettlementGetPayRef, CheckGetPayHeaderRef FROM dbo.FactorCashSettlementCheckBridge WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.FactorCashSettlementCheckBridge
GO
EXECUTE sp_rename N'dbo.Tmp_FactorCashSettlementCheckBridge', N'FactorCashSettlementCheckBridge', 'OBJECT' 
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	PK_FactorCashSettlementCheckBridge PRIMARY KEY CLUSTERED 
	(
	Serial
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
CREATE NONCLUSTERED INDEX IDX_FactorCashSettlementCheckBridge_FactorHeaderRef ON dbo.FactorCashSettlementCheckBridge
	(
	FactorHeaderRef
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IDX_FactorCashSettlementCheckBridge_GritFactorRef ON dbo.FactorCashSettlementCheckBridge
	(
	GritFactorRef
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IDX_FactorCashSettlementCheckBridge_CashGetPayRef ON dbo.FactorCashSettlementCheckBridge
	(
	CashGetPayRef
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IDX_FactorCashSettlementCheckBridge_SettlementGetPayRef ON dbo.FactorCashSettlementCheckBridge
	(
	SettlementGetPayRef
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IDX_FactorCashSettlementCheckBridge_CheckGetPayHeaderRef ON dbo.FactorCashSettlementCheckBridge
	(
	CheckGetPayHeaderRef
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	FK_FactorCashSettlementCheckBridge_FactorHeader FOREIGN KEY
	(
	FactorHeaderRef
	) REFERENCES dbo.FactorHeader
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	FK_FactorCashSettlementCheckBridge_GritFactor FOREIGN KEY
	(
	GritFactorRef
	) REFERENCES dbo.GritFactor
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	FK_FactorCashSettlementCheckBridge_CashGetPay FOREIGN KEY
	(
	CashGetPayRef
	) REFERENCES dbo.CashGetPay
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	FK_FactorCashSettlementCheckBridge_SettlementGetPay FOREIGN KEY
	(
	SettlementGetPayRef
	) REFERENCES dbo.CashGetPay
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.FactorCashSettlementCheckBridge ADD CONSTRAINT
	FK_FactorCashSettlementCheckBridge_CheckGetPayHeader FOREIGN KEY
	(
	CheckGetPayHeaderRef
	) REFERENCES dbo.CheckGetPayHeader
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
COMMIT
