Example 2 – Verifying a Customer Record Using Procedure
Now, let’s create aprocedures for verifing a customer from the Customer table.
CREATE PROCEDURE verify_customer
@id INT,
@name VARCHAR(100),
@address VARCHAR(255)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @verification_status VARCHAR(50);
IF EXISTS (SELECT 1 FROM Customer WHERE id = @id)
BEGIN
IF EXISTS (SELECT 1 FROM Customer WHERE id = @id AND name = @name AND adress = @address)
BEGIN
SET @verification_status = 'Verified';
END
ELSE
BEGIN
SET @verification_status = 'Identity Mismatch';
END
END
ELSE
BEGIN
SET @verification_status = 'Customer Not Found';
END
SELECT @verification_status AS VerificationStatus;
END;
Output
lets execute the procedure and verify a customer.
EXEC [dbo].[verify_customer]
@id = 1,
@name = N'abul',
@address = N'lucknow';
EXEC [dbo].[verify_customer]
@id = 1,
@name = N'abdul',
@address = N'lucknow';
EXEC [dbo].[verify_customer]
@id = 2,
@name = N'abul',
@address = N'lucknow';
What are Stand-Alone Procedures?
Stand-Alone procedures are fundamental components in modern database systems. They make things organized, fast, and safe. Learning about these procedures helps people managing databases to create good ones. Using simple procedures right means data work flows smoothly.
In this article, we will see about stand-alone procedures. It will cover what they are, everyday terms, and why they are important in managing databases. By using simple explanations and examples, you’ll learn how these procedures help to organize database tasks and better the system’s performance.
Contact Us