1 Answers
Usage of Stored Procedures in T-SQL
Stored Procedures in T-SQL are precompiled SQL statements that are stored in the database and can be called by applications or other stored procedures. They provide a way to encapsulate and reuse complex queries or operations, improve performance, enhance security, and simplify maintenance.
Example of a Stored Procedure in T-SQL:
CREATE PROCEDURE sp_GetEmployeeDetails
@EmployeeID INT
AS
BEGIN
SELECT FirstName, LastName, Department
FROM Employees
WHERE EmployeeID = @EmployeeID
END
In this example, the stored procedure named sp_GetEmployeeDetails takes an input parameter @EmployeeID, queries the Employees table, and returns the FirstName, LastName, and Department of the employee with the specified EmployeeID.
Please login or Register to submit your answer