Store Procedure:-- These are set of SQL Statements which are grouped in such a way that they execute to do a certain task and make processing of our application fast.
Advantages:- They are stored in precompiled format and therefore are fast.
Only parameters are passed to the backend instead of query therefore less network utilization.
Besides all these the most important advantage of using Stored Procedure which I found is whenever I needs to make any changes in my application then I only have to open the specific procedure do the changes and then saves that one. No need of going into the code again.
How to create :-
CREATE Procedure GetOrders
(
@UserID INT
-- Parameter Declaration
)
AS
BEGIN
select Orders.UserID, Orders.OrderID,Orders.FirstName,Orders.LastName,Orders.OrderStatus FROM Orders WHERE UserID = @UserID
END
Note:- Write this and press F5
How to modify:-
ALTER Procedure GetOrders
(
@UserID INT
)
AS
BEGIN
select Orders.UserID, Orders.OrderID,Orders.FirstName,Orders.LastName,Orders.OrderStatus FROM Orders WHERE UserID = @UserID
END
Note:- Write this and press F5
How to Open:-
sp_helptext GetOrders
Note:- Its is always in good practice to open a procedure in a "Results to Text" Format
0 Comment(s)