May 30, 2017 at 8:04 am
This older query still executes fine as it refers to the "compatibility view" called sysindexes --- but I'd like to upgrade it now...
USE my_UserDB
GO
SELECT TOP 10 'DBCC SHOWCONTIG(' + CAST(id AS NVARCHAR(20)) + ')' + CHAR(10) + 'PRINT '' ''' + CHAR(10)
FROM sysindexes WHERE indid = 1 OR indid = 0 ORDER BY rows DESC
Using output gen'd from the SQL listed above, I can exec: DBCC SHOWCONTIG(1733581214) PRINT ' ' -- (where 1733581214 was gen'd from above statement as well)
to list fragmentation, scan density, etc...
Can someone supply a newer compatible SQL statement to pull from DMV's in SQL 2012, 2014, 2016?
Very much appreciated - thx in advance!
May 30, 2017 at 8:11 am
I think the DMV you're looking for is called something like sys.dm_index_physical_stats. There'll be plenty of sample queries out there if you search for them.
John
May 30, 2017 at 8:20 am
John Mitchell-245523 - Tuesday, May 30, 2017 8:11 AMI think the DMV you're looking for is called something like sys.dm_index_physical_stats. There'll be plenty of sample queries out there if you search for them.John
sys.dm_db_index_physical_stats
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 30, 2017 at 2:16 pm
Express12 - Tuesday, May 30, 2017 8:04 AMThis older query still executes fine as it refers to the "compatibility view" called sysindexes --- but I'd like to upgrade it now...USE my_UserDB
GO
SELECT TOP 10 'DBCC SHOWCONTIG(' + CAST(id AS NVARCHAR(20)) + ')' + CHAR(10) + 'PRINT '' ''' + CHAR(10)
FROM sysindexes WHERE indid = 1 OR indid = 0 ORDER BY rows DESCUsing output gen'd from the SQL listed above, I can exec: DBCC SHOWCONTIG(1733581214) PRINT ' ' -- (where 1733581214 was gen'd from above statement as well)
to list fragmentation, scan density, etc...Can someone supply a newer compatible SQL statement to pull from DMV's in SQL 2012, 2014, 2016?
Very much appreciated - thx in advance!
For things like this, a quick Google search for the syntax (DBCC SHOWCONTIG, in this case) takes you right to the answer. It's covered in the very first item listed by Microsoft "docs".
--Jeff Moden
Change is inevitable... Change for the better is not.
May 30, 2017 at 5:57 pm
Jeff Moden - Tuesday, May 30, 2017 2:16 PMExpress12 - Tuesday, May 30, 2017 8:04 AMThis older query still executes fine as it refers to the "compatibility view" called sysindexes --- but I'd like to upgrade it now...USE my_UserDB
GO
SELECT TOP 10 'DBCC SHOWCONTIG(' + CAST(id AS NVARCHAR(20)) + ')' + CHAR(10) + 'PRINT '' ''' + CHAR(10)
FROM sysindexes WHERE indid = 1 OR indid = 0 ORDER BY rows DESCUsing output gen'd from the SQL listed above, I can exec: DBCC SHOWCONTIG(1733581214) PRINT ' ' -- (where 1733581214 was gen'd from above statement as well)
to list fragmentation, scan density, etc...Can someone supply a newer compatible SQL statement to pull from DMV's in SQL 2012, 2014, 2016?
Very much appreciated - thx in advance!
For things like this, a quick Google search for the syntax (DBCC SHOWCONTIG, in this case) takes you right to the answer. It's covered in the very first item listed by Microsoft "docs".
For mapping the old base system tables, the page at https://docs.microsoft.com/en-us/sql/relational-databases/system-tables/mapping-system-tables-to-system-views-transact-sql shows a bunch of them. Beyond that, just search for the individual name.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply