Solved

sp_executesql. any advantages of using this in my select statement?

Posted on 2007-12-06
2
243 Views
Last Modified: 2008-02-01
i wonder is there any performance gain if my select statement start with sp_executesql? in term of execution plan will I have any advamtages by using this sp?
0
Comment
Question by:motioneye
2 Comments
 
LVL 27

Assisted Solution

by:ptjcb
ptjcb earned 150 total points
Comment Utility
Without knowing your sql select statement it is hard to know.

FROM http://msdn2.microsoft.com/en-us/library/ms188001.aspx

Being able to substitute parameters in sp_executesql offers the following advantages to using the EXECUTE statement to execute a string:

    * Because the actual text of the Transact-SQL statement in the sp_executesql string does not change between executions, the query optimizer will probably match the Transact-SQL statement in the second execution with the execution plan generated for the first execution. Therefore, SQL Server does not have to compile the second statement.
    * The Transact-SQL string is built only one time.
    * The integer parameter is specified in its native format. Casting to Unicode is not required.
0
 
LVL 31

Accepted Solution

by:
James Murrell earned 350 total points
Comment Utility
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now