Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROC usp_DeleteEmployeesFromDepartment (@departmentId INT)
- AS
- ALTER TABLE Departments
- ALTER COLUMN ManagerID int NULL
- ALTER TABLE Employees
- DROP FK_Employees_Departments
- ALTER TABLE Employees
- DROP FK_Employees_Employees
- ALTER TABLE Departments
- DROP FK_Departments_Employees
- ALTER TABLE EmployeesProjects
- DROP FK_EmployeesProjects_Employees
- DELETE FROM Employees
- WHERE Employees.DepartmentID = @departmentId
- DELETE FROM Departments
- WHERE Departments.DepartmentID = @departmentId
- SELECT COUNT(*) FROM Employees
- WHERE DepartmentID = 7
Advertisement
Add Comment
Please, Sign In to add comment