Query To Find Statistics For Specific Table


   
  /**** All Statistics for particular table*******/
          Use  database_name
          GO
          Select object_name(object_id) as TABLE_NAME ,name as STATS_NAME,
          Case auto_created  when 0
          Then  'auto_created' Else 'User_Created' end as CREATED_BY
          from SYS.STATS where object_name(object_id) = 'Table_Name'
         
/*****************************************/

          Example:

          Create database A
          GO
          use A
          GO
          Create table a(a int , b int)
          GO
          insert into a values (1,1)
          CREATE STATISTICS [stats_a_a] ON [dbo].[a]([a])
          CREATE STATISTICS [stats_a_b] ON [dbo].[a]([b])
          GO
          ---- All statistics on pirticular table
          Select object_name(object_id) as TABLE_NAME ,name as STATS_NAME,
          Case auto_created  when 0
          Then  'auto_created' Else 'User_Created' end as CREATED_BY
          from SYS.STATS where object_name(object_id) = 'a'

Output:

No comments:
Write comments

Please do not enter spam links

Meet US

Services

More Services