SQL-Create Stored Procedure in SQL Server:

Creating and Managing Stored Procedure in SQL Server:

In this post we learn how to work with Sql-store procedure. In my old post we describe what the Store procedure and how many types ofprocedure in sql.

Benefits of Stored Procedures:

  • Stored Procedures reduce the overhead of compiling each time.
  • Stored Procedures also help in preventing SQL Injections since parameters are used in it.
  • Create once and call it N number of times
  • Reduce traffic since instead of whole query only stored procedure name is sent from front end
  • You can give selected users right to execute a particular stored procedure.


How to create stored procedure in sql:

Basically there are two types by which we can create sql procedure.
  • Create by code.
  • Create by GUI.


Sql- Create a Stored Procedure by sql code:

create Procedure Poc_Login
(
-- Declear variable here .....
@QueryType varchar(50)=null,
@Name varchar(50)=null,
@Password varchar(50)=null
)

As
begin
--write your bussionss Login here.
select Name from Login_table

end

SQL-Create Stored Procedure in SQL Server:


we can create store procedure simalarlly. When I am working in my own project the we use seprate procedure for each table.by this you can make all posible queries and run these queries when you want by procedure.

How to Run This Procedure in sql server:

USE [my_testing]
GO

DECLARE     @return_value int

EXEC  @return_value = [dbo].[Poc_Login]

SELECT      'Return Value' = @return_value

GO


Sql- Create a Stored Procedure by GUI:

We explain these by some steps.
  • Step 1: Open the sql server make database with defined tables.
  • Step2: Explore the database –> Table-> Programmability-> Store Procedure.
  • Step3: Right Click on Store Procedure And select New Procedure.



Here we give a Image that’s help for butter understanding.

SQL-Create Stored Procedure in SQL Server:


Other Sql Server Post:




Comments