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
Solved

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

Posted on 2007-12-06
2
250 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
Viewers will learn how the fundamental information of how to create a table.

840 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