MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
-- Check fragmentation on db(sample) Declare @dbid INT Set @dbid =DB_ID('sample') select dbschemas.[name] as 'Schema', dbtables.[name] as 'Table', dbindexes.[name] as 'Index', indexstats.avg_fragmentation_in_percent, indexstats.page_count from sys.dm_db_index_physical_stats (@dbid, NULL, NULL, NULL, NULL) as indexstats INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] INNER JOIN sys.indexes as dbindexes on dbindexes.[object_id] = indexstats.[object_id] AND indexstats.index_id = dbindexes.index_id where indexstats.database_id = @dbid order by indexstats.avg_fragmentation_in_percent desc
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|What type of testing am I doing?||4||74|
|Server 2012 r2 and SQL 2014||6||33|
|SQL Server 2012 to SQL Server 2016||24||53|
|Please explain the difference between EXCLUDE, INTERSECT and JOIN||7||49|
Join the community of 500,000 technology professionals and ask your questions.