/* 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 HumanResources.EmployeeDepartmentHistory
DROP CONSTRAINT FK_EmployeeDepartmentHistory_Department_DepartmentID
GO
ALTER TABLE HumanResources.Department SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE HumanResources.EmployeeDepartmentHistory ADD CONSTRAINT
FK_EmployeeDepartmentHistory_Department_DepartmentID FOREIGN KEY
(
DepartmentID
) REFERENCES HumanResources.Department
(
DepartmentID
) ON UPDATE CASCADE
ON DELETE CASCADE
GO
DECLARE @v sql_variant
SET @v = N'Foreign key constraint referencing Department.DepartmentID.'
EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'HumanResources', N'TABLE', N'EmployeeDepartmentHistory', N'CONSTRAINT', N'FK_EmployeeDepartmentHistory_Department_DepartmentID'
GO
ALTER TABLE HumanResources.EmployeeDepartmentHistory SET (LOCK_ESCALATION = TABLE)
GO
COMMIT