Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-12-06
2
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Assisted Solution

by:ptjcb
ptjcb earned 450 total points
ID: 20420263
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 1050 total points
ID: 20420395
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

636 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