Skip to content

Instantly share code, notes, and snippets.

@robsonalves
Last active October 21, 2015 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsonalves/253c5ad8799507a16a31 to your computer and use it in GitHub Desktop.
Save robsonalves/253c5ad8799507a16a31 to your computer and use it in GitHub Desktop.
Indexes não utilizados
select
db_name() as DataBaseName
,SCHEMA_NAME(O.schema_id) as SchemaNAme
,OBJECT_NAME(I.object_id) as TableName
,I.Name as IndexName
from sys.indexes I
inner join sys.objects O on I.object_id = O.object_id
left outer join sys.dm_db_index_usage_stats S on S.object_id = I.object_id
and I.index_id = S.index_id and database_id = DB_ID()
where OBJECTPROPERTY(o.object_id,'IsMsShipped') = 0
and i.name is not null
and s.object_id is null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment