Simple Stored Procedure in SQL Server

A stored procedure is a compiled program stored in a database for fast execution. It is ideal for repetitive tasks. In this example i will create a simple stored procedure, for those people who want to quickly start programming in Sql Server.

Lets get our hand Dirty.


Create procedure sp_empByID
@eid INT
AS
BEGIN
SELECT * from emp where emp_id=@eid;
END
GO

Execute this procedure. The procedure will compile and created.

Now execute the procedure by typing this in the Query Window

 sp_empByID 13

This will return the record for the Employee which has an ID of 13


No comments:

Post a Comment

Running Drupal in Docker

I will assume that you have already installed docker. If you haven't installed docker please visit https://www.docker.com/ to download a...