Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tablenames as variables?
Message
 
 
To
19/10/2006 14:30:34
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01005583
Message ID:
01163423
Views:
15
>
>Dmitry,
>
>SPT code is the same as an ad-hoc query. SQL Server compiles a new query plan for every ad-hoc query. For a complex query with many joined tables, derived tables, unions etc. SQL Server can take 30 seconds or more to compile the query plan. Using a stored procedure in that case is a speed gain because the query plan is cached. For simpler queries, the compilation time is miniscule but not zero. On a high-volume server, every bit of performance counts so I would put as much as possible into stored procedures. On lower-volume servers, the only concern is the response time for the user so you can get away with a more ad-hoc queries.
>
>sp_executesql is the best of both worlds. Query plans from sp_executesql are cached so subsequent calls with very similar queries will use the cached plan and save any compilation time.

Keith,

I will look up the syntax of using sp_executesql in BOL. Thank you very much for your input.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform