0% found this document useful (0 votes)
76 views

SQL Server Interview Questions - Advantages of Stored Procedures

This document discusses some of the key advantages of using stored procedures over ad-hoc queries in SQL Server. It lists four main advantages: 1) better performance due to caching of execution plans, 2) better security by preventing SQL injection attacks, 3) reduced network traffic by sending only the procedure name between client and server, and 4) better maintainability and reusability by making changes in a single location rather than multiple queries.

Uploaded by

parashuram n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

SQL Server Interview Questions - Advantages of Stored Procedures

This document discusses some of the key advantages of using stored procedures over ad-hoc queries in SQL Server. It lists four main advantages: 1) better performance due to caching of execution plans, 2) better security by preventing SQL injection attacks, 3) reduced network traffic by sending only the procedure name between client and server, and 4) better maintainability and reusability by making changes in a single location rather than multiple queries.

Uploaded by

parashuram n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

12/24/2016 SQL Server Interview Questions: Advantages of stored procedures

2   More    Next Blog» Create Blog   Sign In

SQL Server Interview Questions
C#
Boo MV ASP. C SQL W Written HR Subsc SQL Buy
Program 2
ks C NET # Server CF Test Round ribe Tutorial DVD
s

If you like this website, please share


this site using g+1 button Advantages of stored procedures
+2   Recommend this on Google
This is a very common sql server interview question. There are several
advantages of using stored procedures over adhoc queries, as listed below.

1. Better Performance : Stored Procedures are compiled and their execution
plan is cached and used again, when the same SP is executed again. Although
adhoc queries also create and reuse plan, the plan is reused only when the
query is textual match and the datatypes are matching with the previous call.
Any change in the datatype or you have an extra space in the query then, a new
Best software training institute in bangalore for SAP ABAP,
plan is created.
SAP BI, .Net, Informatica, Software Testing, Siebel CRM
I am Venkat and this is my website. I did training in Pragim
2. Better Security : Applications making use of dynamically built adhoc sql
Technologies and got job in Dell in less than a week. PRAGIM is the queries are highly

{
best S/W training institute in Bangalore. susceptible to sql injection
Click here for Hyderabad Center Website attacks, where as Stored

Take: [“the”],
For further details please call 09900113931. Procedures can avoid
SQL injection attacks
Android: completely.

“course” 3. Reduced Network
Traffic: Stored procedures
} can reduce network traffic
to a very great extent
when compared with
adhoc sql queries. With
stored procedures, you
only need to send the
name of the procedure
between client and server.
Imagine the amount of
network bandwith that can be saved especially if the stored procedure contains
1000 to 2000 lines of SQL.

4. Better Maintainance and Reusability: Stored procedures can be used any
where in the application. It is easier to maintain a stored procedure that is used
SAP BI Training in Bangalore on several pages as the modfifcations just need to be changed at one place
Best SAP BI Training institute in Bangalore, where the stored procedure is defined. On the other hand, maintaining an adhoc
Marathahalli. Real time project based training sql query that's used on several pages is tedious and error prone, as we have to
provided by working software professionals make modifications on each and every page.
having more than 10 years of experience.
Informatica Training in Bangalore If you can think of any other advantage of using stored procedures, please
Informatica training in bangalore delivered by contribute by submitting the form below.
a real time software expert having 10 years
of experience. 
Siebel CRM Training in Bangalore
Best software training institute for Siebel CRM
training in Marathahalli, Bangalore. 
Software testing training institute in
bangalore

http://venkatsqlinterview.blogspot.in/2011/07/advantages­of­stored­procedures.html 1/3
12/24/2016 SQL Server Interview Questions: Advantages of stored procedures

Software testing training on real time projects
and placements. 
MSBI Training Institute in Bangalore
Best MSBI Training in Bangalore by an
expert. MSBI training on real time projects
and placements. 
Basic SQL Server Interview Questions

SQL Server Interview Questions on


Temporary Tables

SQL Server Interview Questions on Airtel Postpaid Plans


Indexes ‐ Part 1
Get MyPlan with Great Bene飋�ts and
SQL Server Interview Questions on Packs. Browse for Details.
Indexes ‐ Part 2 www.airtel.in/myplan

What is the difference between +2   Recommend this on Google


Having and Where clause

What is the difference between a


Temporary Table and a Table Variable 7 comments:

What is the use of COALESCE in SQL


Server yener November 22, 2011 at 12:16 PM
SQL Server Interview Questions on SQL Server creates a cache entry for the execution plans of
triggers Stored procedures when they are first run. On subsequent runs,
if the execution plan matches, this provides a performance
Difference between User Defined advantage.
Function and Stored Procedure
Reply
SQL Server Interview Questions on
Views ‐ Part 1
Anonymous May 15, 2013 at 2:16 PM
SQL Server Interview Questions on
Views ‐ Part 2 With stored procedures, you can make changes to data
retrieval operations at any time without affecting users or
Basic SQL Server Interview Questions having to re‐distribute your application code. For example if
on Joins you have a query with a "where..." clause and you need to
change the criteria, just modify the stored procedure (from
Explain Inner Join with an example SSMS), make the change, run the update code and you're back
in business. With text‐based queries from your application, such
Explain Left Outer Join with an as linq, you need to republish or redistribute your application!
example
Reply
Explain Right Outer Join with an
example
Anonymous May 19, 2013 at 7:09 AM
Explain Full Outer Join with an
example Hi Venkat,

Explain Self Join with an example Can you post examples, it will be good to understand..
What is the difference between Index Reply
Scan and Index Seek

Write a SQL Query to delete from a Stephen Mathew August 8, 2014 at 8:45 PM
table that is involved in a SQL join
Since, SQL Security permissions can be placed on SPs, they are
What are the advantages of using more secure.
stored procedures
Reply
What are the different ways to
replace NULL values in SQL Server
http://venkatsqlinterview.blogspot.in/2011/07/advantages­of­stored­procedures.html 2/3
12/24/2016 SQL Server Interview Questions: Advantages of stored procedures

MASAUD August 9, 2014 at 10:53 PM


SQL Server interview questions on
string manipulation functions Another Advantage of using Stored Procedure is to
Avoids SQL Injection Attacks
Write a Stored Procedure that takes Reply
column name as a parameter and
returns the result sorted by the
column that is passed
Veeshal Mali June 25, 2015 at 9:21 PM
What is deferred name resolution in
SQL Server?
Stored Procedure is Compiled block of code. It compiles once till
we alter the sp and we can execute it again and again. But
when we use SQL Queries it compiles every time and then
executes. So SQL Queries takes more time compare to SQL SP.
So SP is better than SQL Queries for performance.
Reply

Replies

Pradeep October 25, 2016 at 7:51 PM


Please how it compiles once ,let me know with one
real word example as I am new to it

Reply

Enter your comment...

Comment as:  Select profile...

Publish
  Preview

If you are aware of any other sql server questions asked in an


interview, please post them below. If you find anything missing or
wrong, please feel free to correct by submitting the form below.

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

 
Disclaimer ­ Terms of use ­ Contact Us

http://venkatsqlinterview.blogspot.in/2011/07/advantages­of­stored­procedures.html 3/3

You might also like