Use ATNDBTest
Go

/*
   Monday, April 3, 20179:59:23 PM
   User: 
   Server: TAHERIAN
   Database: ATNDBTest
   Application: 
*/

/* 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
CREATE TABLE dbo.Tmp_Degree
	(
	Serial smallint NOT NULL,
	Code smallint NULL,
	FADescription varchar(50) NULL,
	ENDescription varchar(50) NULL,
	Comment varchar(300) NULL,
	RecorderRef int NULL,
	RecordDate char(10) NULL,
	EditorRef int NULL,
	EditDate char(10) NULL,
	OfficeDetailRef int NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_Degree SET (LOCK_ESCALATION = TABLE)
GO
IF EXISTS(SELECT * FROM dbo.Degree)
	 EXEC('INSERT INTO dbo.Tmp_Degree (Serial, FADescription, Comment)
		SELECT Serial, Description, Comment FROM dbo.Degree WITH (HOLDLOCK TABLOCKX)')
GO
ALTER TABLE dbo.PartSalePrice
	DROP CONSTRAINT FK_PartSalePrice_Degree
GO
ALTER TABLE dbo.GritSalePrice
	DROP CONSTRAINT FK_GritSalePrice_Degree
GO
ALTER TABLE dbo.GetterOrPayerFactor
	DROP CONSTRAINT FK_GetterOrPayerFactor_Degree
GO
DROP TABLE dbo.Degree
GO
EXECUTE sp_rename N'dbo.Tmp_Degree', N'Degree', 'OBJECT' 
GO
ALTER TABLE dbo.Degree ADD CONSTRAINT
	PK_Degree PRIMARY KEY CLUSTERED 
	(
	Serial
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.GetterOrPayerFactor ADD CONSTRAINT
	FK_GetterOrPayerFactor_Degree FOREIGN KEY
	(
	DegreeRef
	) REFERENCES dbo.Degree
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.GetterOrPayerFactor SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.GritSalePrice ADD CONSTRAINT
	FK_GritSalePrice_Degree FOREIGN KEY
	(
	DegreeRef
	) REFERENCES dbo.Degree
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.GritSalePrice SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.PartSalePrice ADD CONSTRAINT
	FK_PartSalePrice_Degree FOREIGN KEY
	(
	DegreeRef
	) REFERENCES dbo.Degree
	(
	Serial
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
	
GO
ALTER TABLE dbo.PartSalePrice SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
