CREATE PROCEDURE spEmployee AS
BEGIN
SELECT EmployeeId, Name, Gender, DepartmentName FROM tblEmployees INNER JOIN tblDepartments ON tblEmployees.EmployeeDepartmentId = tblDepartments.DepartmentId
END
Advantages of using a Stored Procedure in SQL Server
• It is very easy to maintain a Stored Procedure and they are re-usable.
• The Stored Procedure retains the state of the execution plans.
• Stored Procedures can be encrypted and that also prevents SQL Injection Attacks