Use ATNDBTest
Go



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_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,
	SettlementGetPayRef bigint NULL,
	CheckGetPayHeaderRef 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, CashGetPayRef, SettlementGetPayRef, CheckGetPayHeaderRef)
		SELECT Serial, FactorHeaderRef, 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
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_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
