Thursday, July 23, 2015

IndexUsageAnalysis

USE [SysAdmin]
GO

/****** Object:  Table [dbo].[DATAUSAGEANALYSIS]    Script Date: 1/28/2015 5:14:29 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[DATAUSAGEANALYSIS](
[db_name] [nvarchar](128) NULL,
[schema_name] [nvarchar](128) NULL,
[table_name] [nvarchar](128) NULL,
[index_name] [sysname] NULL,
[type] [varchar](4) NULL,
[is_unique] [bit] NULL,
[cnstr] [varchar](2) NULL,
[key_columns] [nvarchar](max) NULL,
[included_columns] [nvarchar](max) NULL,
[location] [sysname] NOT NULL,
[rows] [bigint] NULL,
[pages] [bigint] NULL,
[MB] [decimal](9, 2) NULL,
[user_seeks] [bigint] NULL,
[user_scans] [bigint] NULL,
[user_lookups] [bigint] NULL,
[user_updates] [bigint] NULL,
[Statistics_last_collected] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO



EXEC master..sp_MSForeachdb '
USE [?]
IF ''?'' <> ''master'' AND ''?'' <> ''model'' AND ''?'' <> ''msdb'' AND ''?'' <> ''tempdb''
BEGIN
INSERT INTO SYSADMIN..DATAUSAGEANALYSIS
exec [?]..sp_indexinfo @missing_ix = 0
END
'




select * from SYSADMIN..DATAUSAGEANALYSIS

No comments: