What is the Stored Procedure? Create a Procedure to find the record by stu_ID from the student table.
What is the Stored Procedure? Create a Procedure to find the record by stu_ID from the student table
507
24-Mar-2023
Krishnapriya Rajeev
12-Apr-2023In SQL, a stored procedure is a pre-compiled collection of SQL statements and procedural logic that can be executed repeatedly by invoking the procedure. Stored procedures are stored in the database and can be used to encapsulate complex business logic, improve performance, and simplify database administration.
Here's an example of how to create a stored procedure in SQL Server to find a student record by their stu_ID from the student table:
In this example, the CREATE PROCEDURE statement is used to create a stored procedure called find_student. The procedure takes one input parameter, @stu_ID, which is an integer representing the student ID.
The SELECT statement is used to retrieve the student record from the student table where the stu_ID matches the input parameter @stu_ID.
To execute the stored procedure, you can use the EXECUTE statement, passing in the value of @stu_ID as a parameter:
This will return the student record from the student table where the stu_ID is 12.