Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

Query text during caching in SQL 2005 Expand / Collapse
Author
Message
Posted Monday, November 15, 2010 9:24 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 5:13 AM
Points: 1,131, Visits: 1,394
Oleg Netchaev (11/15/2010)
Carlo Romagnano (11/14/2010)
In sql2005, I get an error:
"plan_handle" is not a recognized table hints option.

Carlo,

Please check compat level of your SQL Server 2005 AdventureWorks database. If the level is 80 then you should get "plan_handle" is not a recognized table hints option error, but if it is 90 as it should be then the script should run just fine.

Oleg

Thanks for resolving the issue, due to project work not able to answer.


Thanks
Post #1021196
Posted Monday, November 15, 2010 10:07 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 5:13 AM
Points: 1,131, Visits: 1,394
Hugo Kornelis (11/14/2010)
Good question. I answered wrong; I thought all statements were cached.

Hardik, do you have any references where I can read more about this?

Thanks Hugo. Sorry I don't have material for the same. I learned this when I face similar type of issue (I asked Pinal who is SQL Server MVP). So, thought to share to all


Thanks
Post #1021205
Posted Monday, November 15, 2010 10:09 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 5:13 AM
Points: 1,131, Visits: 1,394
Carlo Romagnano (11/15/2010)
Execute the batch without the 'GO'

EXEC uspLogError
SELECT st.text QueryText,objtype
FROM sys.dm_exec_cached_plans
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS st
WHERE text LIKE N'%uspLogError%'

Result:
CREATE PROCEDURE [dbo].[uspLogError] ....,'Proc'
EXEC uspLogError SELECT st.text QueryText FROM sys.dm_exec_cached_plans ....,'Adhoc'


The body of the stored procedure is cached in the objtype = 'Proc' (see also other info about the proc). the second record is the plan stored with objtype = 'Adhoc'

See also: http://msdn.microsoft.com/en-us/library/ms187404.aspx

Execute the batch with GO - is the real part. thanks for validating & provide to link to all.


Thanks
Post #1021208
Posted Monday, November 15, 2010 10:10 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 5:13 AM
Points: 1,131, Visits: 1,394
RichardDouglas (11/15/2010)
Good question, thanks for taking the time to help educate the SQL community.

I look at these DMV's a lot so thankfully answered this one correctly.

Good to know.


Thanks
Post #1021209
Posted Wednesday, November 24, 2010 11:14 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 3:20 PM
Points: 18,064, Visits: 16,099
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1026077
Posted Tuesday, May 24, 2011 8:29 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 1, 2014 7:44 AM
Points: 457, Visits: 349
Good Question

_____________________________________________

Kindest Regards,
- Tushar
MCP,MCDBA(SQL 2000),MCTS(SQL 2005),MCITP(SQL 2005)

" Most Good Experience Comes From Judgement,
Most Judgement Comes From Bad Experience "
Post #1114075
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse