While it's still only the CTP1 timeframe, getting a glimpse of the changes in system objects can start preparing you for what's coming - especially when there are potential breaking changes, as you'll see below. Sure, a few of these things can change (and hopefully be fixed!) as the product gets closer to release, but once you have the scripts on disk, you can take a pulse at any time. Obviously, queries that go after the system objects directly are going to be much less tedious and annoying than trying to parse Books Online for changes (even if you assume that Books Online is up to date - which, as you'll see below, is not the case).
Before starting, I'll assume that you have a 2008 R2 instance and a Denali instance; these instances should have valid linked servers pointing at each other. In the code below you will see references to fairly intuitive linked server names: [GREENLANTERN\SQL2008R2] and [GREENLANTERN\DENALI]. I will try to remember to make it clear which instance the code should run from (in a few cases it matters, because functions like OBJECT_SCHEMA_NAME() don't work remotely without using <linked server>...sp_executeSQL).
New system objects in SQL Server "Denali"
This is a query run from the Denali server that will find objects that did not exist in 2008 R2. I had to code in an exclusion in the where clause; while sp_MS_marksystemobject certainly exists in 2008 R2, it does not appear in sys.all_objects the way it does in Denali.
SELECT [name] = N'sys.' + o.name, [type] = o.type_desc FROM [master].sys.all_objects AS o LEFT OUTER JOIN [GREENLANTERN\SQL2008R2].[master].sys.all_objects AS oo ON o.name = oo.name AND o.[schema_id] = oo.[schema_id] WHERE oo.name IS NULL AND o.[schema_id] = 4 AND o.name <> N'sp_MS_marksystemobject' ORDER BY o.type_desc, o.name;
|
Some of these objects are documented, but several still are not listed in the current version of Denali BOL. I was going to remove the links for the items that aren't documented, but I'll leave all of the search links intact so that they will continue to work when they *are* added to Books Online.
System objects dropped in SQL Server "Denali"
We can run a query similar to the above from the 2008 R2 instance, to see what kind of things will no longer work in Denali.
SELECT [name] = N'sys.' + o.name, [type] = o.type_desc FROM [master].sys.all_objects AS o LEFT OUTER JOIN [GREENLANTERN\DENALI].[master].sys.all_objects AS oo ON o.name = oo.name AND o.[schema_id] = oo.[schema_id] WHERE oo.name IS NULL AND o.[schema_id] = 4 ORDER BY o.type_desc, o.name;
|
The results: these are mostly XPs that have been marked for deprecation several versions ago (and actually are still marked as "future deprecated" in the current Denali Books Online - see Connect #625200) However I cannot yet explain the service broker DMV that is missing; I filed a bug about this in Connect #625206.
DMV / Catalog View columns added or changed in SQL Server "Denali"
This query, run on the Denali instance, will show new or changed columns compared to SQL Server 2008 R2:
;WITH r AS ( SELECT c.[object_id], [schema] = OBJECT_SCHEMA_NAME(c.[object_id]), viewname = v.name, col = c.name, t = c.system_type_id, [type] = t.name, c.[precision], c.scale, c.max_length FROM [master].sys.all_columns AS c INNER JOIN [master].sys.all_views AS v ON c.[object_id] = v.[object_id] INNER JOIN [master].sys.types AS t ON t.system_type_id = c.system_type_id WHERE t.name <> N'sysname' ) SELECT [status] = CASE WHEN l.viewname IS NULL THEN 'new' ELSE 'changed' END, r.[schema], r.viewname, r.col, r.[type], FormerType = l.[type], r.[precision], FormerPrecision = l.[precision], r.scale, FormerScale = l.scale, max_length = r.max_length / CASE WHEN r.[type] = N'nvarchar' THEN 2 ELSE 1 END, FormerMaxLength = l.max_length / CASE WHEN l.[type] = N'nvarchar' THEN 2 ELSE 1 END FROM r LEFT OUTER JOIN ( SELECT [schema] = s.name, viewname = v.name, col = c.name, t = c.system_type_id, [type] = t.name, c.[precision], c.scale, c.max_length FROM [GREENLANTERN\SQL2008R2].[master].sys.all_columns AS c INNER JOIN [GREENLANTERN\SQL2008R2].[master].sys.all_views AS v ON c.[object_id] = v.[object_id] INNER JOIN [GREENLANTERN\SQL2008R2].[master].sys.schemas AS s ON v.[schema_id] = s.[schema_id] INNER JOIN [GREENLANTERN\SQL2008R2].[master].sys.types AS t ON c.system_type_id = t.system_type_id WHERE t.name <> N'sysname' ) AS l ON r.viewname = l.viewname AND r.[schema] = l.[schema] AND r.col = l.col WHERE ( l.col IS NULL OR ( r.t <> COALESCE(l.t, -10) OR r.[precision] <> COALESCE(l.[precision], -10) OR r.scale <> COALESCE(l.scale, -10) OR r.max_length <> COALESCE(l.max_length, -10) ) ) AND EXISTS ( SELECT 1 FROM [GREENLANTERN\SQL2008R2].[master].sys.all_views WHERE name = r.viewname ) ORDER BY [status] DESC, r.viewname, r.col;
|
The results: many new property columns for sys.databases, several new (well, renamed; see below) memory usage indicators in a few key DMVs, and some new columns around contained databases. (Please note that not all of the columns should imply that those
features, e.g. two-digit year cutoff, will be supported in the next
major version of SQL Server.) Also, a handful of the big string columns in various DMVs have been widened from 256 or 2,048 characters to 3,072; I'm not sure if any of these caused bugs in earlier versions, or they are just being proactive.
DMV / Catalog View columns dropped from SQL Server "Denali"
And finally, we should check for columns that have been dropped from DMVs or catalog views, since cpu_ticks_in_ms was dropped from sys.dm_os_sys_info in SQL Server 2008 with little fanfare. On the 2008 R2 instance, you can run this query:
;WITH r AS ( SELECT c.[object_id], [schema] = OBJECT_SCHEMA_NAME(c.[object_id]), viewname = v.name, col = c.name FROM [master].sys.all_columns AS c INNER JOIN [master].sys.all_views AS v ON c.[object_id] = v.[object_id] ) SELECT r.[schema], r.viewname, r.col FROM r LEFT OUTER JOIN ( SELECT [schema] = s.name, viewname = v.name, col = c.name FROM [GREENLANTERN\DENALI].[master].sys.all_columns AS c INNER JOIN [GREENLANTERN\DENALI].[master].sys.all_views AS v ON c.[object_id] = v.[object_id] INNER JOIN [GREENLANTERN\DENALI].[master].sys.schemas AS s ON v.[schema_id] = s.[schema_id] ) AS l ON r.viewname = l.viewname AND r.[schema] = l.[schema] AND r.col = l.col WHERE l.col IS NULL AND EXISTS ( SELECT 1 FROM [GREENLANTERN\DENALI].[master].sys.all_views WHERE name = r.viewname ) ORDER BY r.viewname, r.col;
|
The results: as it turns out, the only columns that have been "dropped" are the ones that have been renamed or consolidated (they are listed as new above).
If you're currently using any of these DMVs in your own code, this is potentially a major breaking change - you may want to make note of the columns that have changed, as upgrading to Denali may break some of your scripts.