What is a stored procedure

0 votes

What is the make-up of a stored procedure (things each must have to be a stored procedure)?

Feb 4, 2022 in Database by Vaani
• 7,070 points
1,070 views

1 answer to this question.

0 votes

A stored procedure is a set of precompiled SQL statements that are used to perform a special task.

Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples.

To create a stored procedure the syntax is fairly simple:

CREATE PROCEDURE <owner>.<procedure name>

     <Param> <datatype>

AS

     <Body>

So for example:

CREATE PROCEDURE Users_GetUserInfo

    @login nvarchar(30)=null

AS

    SELECT * from [Users]
    WHERE ISNULL(@login,login)=login

Stored procedures also have a security benefit in that you can grant execute rights to a stored procedure but the user will not need to have read/write permissions on the underlying tables. This is a first step against SQL injection.

answered Feb 4, 2022 by Neha
• 9,020 points

Related Questions In Database

0 votes
0 answers

What is the syntax to drop a Stored Procedure in SQL Server 2000?

In SQL Server 2000, how do you ...READ MORE

Aug 25, 2022 in Database by Kithuzzz
• 38,000 points
609 views
0 votes
1 answer

What does recursive stored procedure?

Recursive stored procedure refers to a stored ...READ MORE

answered Sep 27, 2018 in Database by Sahiti
• 6,370 points
15,327 views
0 votes
1 answer

What is a covered Index?

A covering index is an index that contains all ...READ MORE

answered Oct 10, 2018 in Database by Frankie
• 9,830 points
818 views
0 votes
1 answer

What is a Relationship and what are they?

Relation or links are between entities that ...READ MORE

answered Oct 23, 2018 in Database by DataKing99
• 8,250 points
782 views
0 votes
0 answers

What is a stored procedure?

119 What is a "stored procedure" , how do they work? What ...READ MORE

May 27, 2022 in Others by avinash
• 1,840 points
655 views
0 votes
0 answers

Loop in stored procedure in SQL server

Writing a stored procedure that calls another ...READ MORE

Aug 28, 2022 in Database by Kithuzzz
• 38,000 points
1,762 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
832 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,070 points
558 views
0 votes
1 answer

What is the definition of cardinality in SQL?

Cardinality is defined as the "number of ...READ MORE

answered Feb 15, 2022 in Database by Neha
• 9,020 points
1,880 views
0 votes
1 answer

Function vs. Stored Procedure in SQL Server

Functions are calculated values that cannot make ...READ MORE

answered Feb 17, 2022 in Database by Neha
• 9,020 points

edited Feb 17, 2022 by Neha 19,329 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP