Solved

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

Posted on 2007-12-06
2
253 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 150 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 350 total points
ID: 20420395
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

756 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