Tuesday, 11 June 2024

Stored procedures

 Stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.

You can also pass parameters to a stored procedure, so that the stored procedure can act based on the parameter value(s) that is passed.


CREATE PROCEDURE SelectAllCustomers
AS
SELECT * FROM Customers
GO;

EXEC SelectAllCustomers;


CREATE PROCEDURE SelectAllCustomers @City nvarchar(30), @PostalCode nvarchar(10)
AS
SELECT * FROM Customers WHERE City = @City AND PostalCode = @PostalCode
GO;

EXEC SelectAllCustomers @City = 'London', @PostalCode = 'WA1 1DP';

No comments:

Post a Comment

Dynamics 365 — Retrieve More than 5000 records with FetchXML

  When you’re working with Dynamics 365, you may have encountered a limitation when it comes to retrieving records. The maximum number of re...