Definition: stored procedure is a group of transaction statement to perform specific task for desired output.
Benefits :
1) Stored Procedure are compiled once so we can execute stored procedure in a single call and it will not get compiled again and again.It improves performance in executing.
2)All the complicated logic can be written in stored procedure which improves re usability of
3)Using stored procedure we can manage shared logic at one place in sql server,
4) Through stored procedure we can simplify security, administration, and maintenance.applications can call stored procedures that run SQL queries with little or no additional processing.
Sytnax for Creating Stored Procedure:
Create Proc [Procedure name]
---
declare parameters here
---
As
Begin
---
----
write Logics here
---
End
Example:
create proc [salesorderline]
as
begin
select [Sales Doc#] as [Sales Order No.],
Material as [Item Code],
[Description] as [Description],
[Batch] as [Batch No.],
[Order Quantity] as [Quantity],
[UoM] as [Unit],
[Net price] as [Unit Price],
[Net value] as [Amount]
from dbo.[438_Sales_Orders_VBAP] where Material<>''
end
No comments:
Post a Comment