Venciity

EF - Stored Procedure

Mar 7th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.61 KB | None | 0 0
  1. SET ANSI_NULLS ON
  2. GO
  3.  
  4. IF(Object_Id('usp_GetProjectsCountByEmployee') IS NOT NULL)
  5. DROP PROCEDURE usp_GetProjectsCountByEmployee
  6. GO
  7.  
  8. CREATE PROCEDURE usp_GetProjectsCountByEmployee(
  9.     @FirstName NVARCHAR(50),
  10.     @LastName NVARCHAR(50))
  11. AS
  12. BEGIN
  13.     -- SET NOCOUNT ON added to prevent extra result sets from
  14.     -- interfering with SELECT statements.
  15.     SET NOCOUNT ON;
  16.  
  17.     SELECT COUNT(p.ProjectID)
  18.     FROM Employees e
  19.         LEFT OUTER JOIN EmployeesProjects ep ON ep.EmployeeID = e.EmployeeID
  20.         LEFT OUTER JOIN Projects p ON ep.ProjectID = p.ProjectID
  21.         WHERE e.FirstName = @FirstName AND e.LastName = @LastName
  22. END
  23. GO
Advertisement
Add Comment
Please, Sign In to add comment