Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lappin
Posting Yak Master
182 Posts |
Posted - 2010-09-28 : 04:56:16
|
I fill a large table on a schedule using a stored procedure. To minimise logging, inside the procedure I truncate the table then drop it, then fill it with a SELECT INTO, then I Create Indexes.My question is - how do I generate CREATE STATISTICS script to add to the end of the procedure. I have set the database to Autogenerate and Update statistics, but the query optimiser advised additional statistics which I now use. I have tried using "Generate Scripts" and selecting "create statisitics" but the final script has no CREATE STATISTICS section. |
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2010-09-28 : 16:17:28
|
If you want to create statistics for the entire table, something like this:CREATE STATISTICS names ON tablename (Col1, Col2, etc.) WITH FULLSCANLook it up in BOL for further details as you can do a sampling of the data as opposed to fullscan. Personally, I would drop all indexes on the table before adding the data, dependent on how much data is being added and then recreate the indexes. It will recreate your statistics for you as well.Terry-- You can't be late until you show up. |
 |
|
|
|
|