Skip to content

Instantly share code, notes, and snippets.

@muratvezir
Created November 9, 2022 17:58
Show Gist options
  • Save muratvezir/495253588d5229309132e56ccd4c6a75 to your computer and use it in GitHub Desktop.
Save muratvezir/495253588d5229309132e56ccd4c6a75 to your computer and use it in GitHub Desktop.
User Created Staticstic
SELECT DISTINCT 'DROP STATISTICS '
+ SCHEMA_NAME(ob.Schema_id) + '.'
+ OBJECT_NAME(s.object_id) + '.' +
s.name DropStatisticsStatement
FROM sys.stats s
INNER JOIN sys.Objects ob ON ob.Object_id = s.object_id
WHERE SCHEMA_NAME(ob.Schema_id) <> 'sys'
AND Auto_Created = 0 AND User_Created = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment