Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER TABLE Departments
- ALTER COLUMN ManagerId INT NULL
- SELECT EmployeeID
- FROM Employees AS e
- INNER JOIN Departments AS d
- ON E.DepartmentID = D.DepartmentID
- WHERE D.Name IN ('Production', 'Production Control')
- DELETE FROM EmployeesProjects
- WHERE EmployeeID IN
- (
- SELECT EmployeeID FROM Employees AS e
- INNER JOIN Departments AS d
- ON E.DepartmentID = D.DepartmentID
- WHERE D.Name IN ('Production', 'Production Control')
- )
- UPDATE Employees
- SET ManagerID = NULL
- WHERE ManagerID IN
- (
- SELECT EmployeeID FROM Employees AS e
- INNER JOIN Departments AS d
- ON E.DepartmentID = D.DepartmentID
- WHERE D.Name IN ('Production', 'Production Control')
- )
- UPDATE Departments
- SET ManagerID = NULL
- WHERE ManagerID IN
- (
- SELECT EmployeeID FROM Employees AS e
- INNER JOIN Departments AS d
- ON E.DepartmentID = D.DepartmentID
- WHERE D.Name IN ('Production', 'Production Control')
- )
- DELETE FROM Employees
- WHERE EmployeeID IN
- (
- SELECT EmployeeID FROM Employees AS e
- INNER JOIN Departments AS d
- ON E.DepartmentID = D.DepartmentID
- WHERE D.Name IN ('Production', 'Production Control')
- )
- DELETE FROM Departments
- WHERE Name IN ('Production', 'Production Control')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement