Arnab's Blog

Always seeking for new technology

How to Write Stored Procedure


Hello all,
Today we are going to learn how to write a stored procedure in sql server. The following code is a sample one. If you like it you can use this format for all stored procedure…

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

if exists(select * from dbo.sysobjects where id=object_id(N'[dbo].[StoredProcedureName]') and OBJECTPROPERTY(id,N'IsProcedure') == 1)
drop procedure [dbo].[StoredProcedureName]
GO

CREATE PROCEDURE [dbo].[StoredProcedureName]
@prmParameter int
with encryption
AS
declare @ID as nvarchar(4)

Select * from tableName where id = @prmParameter

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Now if you want to execute the sp please write the following command..

exec StoredProcedureName 10

here 10 is the prmParameter value..

thats it…

Thanks..

About these ads

One Response to How to Write Stored Procedure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

SQL Server Journey with SQL Authority

Personal Notes of Pinal Dave

Șic și clasic - "Chic & Classic" luxury fine arts, handmade work, original design

Cand cumperi arta nu cumperi doar ceea ce vezi si pipai cumperi sufletul unui om, sufletul artistului pentru ca el/ artistul s-a uitat in sufletul lui si a scos de acolo ce a gasit

A passion for Small Business

Small Business is Big Business™

geekpython

skilled with python

Follow

Get every new post delivered to your Inbox.