To check the fragmentation of all indexes on the Database

SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName, AS IndexName, indexstats.index_type_desc AS IndexType, indexstats.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats INNER JOIN sys.indexes ind ON ind.object_id = indexstats.object_id AND ind.index_id = indexstats.index_id WHERE indexstats.avg_fragmentation_in_percent > 30 ORDER BY indexstats.avg_fragmentation_in_percent DESC

Capture SQL Server Important Details

Please find the below script to capture SQL Server Important Details before upgrade, migration etc. PRINT ‘***************** Server Name ********************’SET NOCOUNT ONselect @@SERVERNAMEgo PRINT ‘***************** Version ********************’SET NOCOUNT ONselect @@versiongo PRINT ‘***************** License Information********************’SET NOCOUNT ONSELECT SERVERPROPERTY (‘LicenseType’)go PRINT ‘***************** Number of Licenses********************’SET NOCOUNT ONSELECT… Read More