Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting it all from Statistics
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01302337
Message ID:
01302821
Views:
11
>>>While researching an answer to your question I stambled upon this very interesting artcile
>>>
>>>http://www.codeproject.com/KB/database/Dynamic_Management_Views.aspx
>>
>>Thanks, there's a lot of interesting topics in there.
>
>
>Hi Michel,
>
>The code bellow will create statistics for all tables in the database:
>
>
>if object_ID('TempDB..#Stats') is not null
>   drop table #Stats
>
>create table #Stats (TableName varchar(128), Statistics_Name varchar(128), Statistics_Keys varchar(128))
>
>if object_ID('TempDB..#Stats_Temp') is not null
>   drop table #Stats_Temp
>
>create table #Stats_Temp (Statistics_Name varchar(128), Statistics_Keys varchar(128))
>
>exec sp_MSforeachtable
>  'insert into #Stats_Temp execute sp_helpstats ''?'', ''ALL''','?','insert into #Stats select ''?'', * from #Stats_Temp','delete from #Stats_Temp'
>
>
>select * from #Stats
BTW, did you see this answer? I was thinking yesterday too after I read the other link I gave you that we can get the information from the sys.Stats view, but I needed to get the syntax right using my original idea too. Took me quite a while to come up with this solution...
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform