sqlrx logo
SQLRx® Tip of the Month


November 2010
Greetings!

If you performed an in-place upgrade of your SQL Server, your master database may be at a lower compatibility level than all of the other system databases. Learn more below.  Also be sure to regularly monitor the 11 VitalSigns used by SQLRx to debug performance bottlenecks.
___________________________________________________________________
SQL 2008  SQL Server Administration:  If you performed an in-place upgrade of your SQL Server, your master database may be at a lower compatibility level than all of the other system databases. This was done by conscious decision from Microsoft in an attempt to make for a smooth upgrade and ensure that existing applications can still function post-upgrade. This has the negative side effect of not being able to use operators, keywords and other functionality when the database, in whose context you are executing these queries, is not at the right compatibility level.
___________________________________________________________ 

                               

For instance, if you want to examine currently executing queries using SQL 2005 with your master database in 80 compatibility ...

USE master

GO

SELECT s2.dbid,s2.objectid,SUBSTRING (s2.text, s1.statement_start_offset/2 + 1,

CASE WHEN s1.statement_end_offset = -1 THEN 8192

ELSE s1.statement_end_offset/2 - s1.statement_start_offset/2 END + 1) as QueryText

FROM sys.dm_exec_requests s1

CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s2

GO

... you will receive the following error...

Msg 321, Level 15, State 1, Line 5

"sql_handle" is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.

As a workaround, you can execute the same query against tempdb, model or msdb and it will work with no errors.  It is permissible to change the compatibility level of the master database should you find it in a low compatibility level.

-SQL 2005

EXEC sp_dbcmptlevel 'master' , 90

GO

-SQL 2008

EXEC sp_dbcmptlevel 'master' , 100

GO

 _________________________________________________________________

SQLRx is a part of www.msdev.com, a Microsoft training site!  Check the site periodically to view new training videos.
 
If you have a SQL question you'd like us to answer, and possibly use for the next SQLRx Tip of the Month or msdev video, email it to us!  If you missed any of our previous tips, you can view them here.
 
For assistance or more information on optimizing your SQL Server Environment, visit us at www.sqlrx.com or email Lori Brown at lorib@isi85.com.  

Sincerely,

Lori Brown | SQLRx Senior Consultant | Integrated Services, Inc.
4144 N. Central Expwy, Suite 430  |  Dallas, TX  75204
Phone: 214.526.7680 x 113 | lorib@isi85.com 
 
 
Integrated Services, Inc.                                    
2008 winner logo small
Turning Data Into Profit
 
25 Years of Credibility & Trust
 

Join our email list          Check out our events          SQLRx Downloads