Tuesday, March 27, 2012

delete all statistics in db

Hi,
anybody have a script or an idea on how to delete all stats in a db?
while on the topic why do some stats (column I think) prevent column from
being upgraded via alter table statement? I would have expected stats to be
dropped as soon as column modified.
Thanks.Try the following post from Dan Guzman:
http://groups.google.com/group/microsoft.public.sqlserver.server/msg/8dd9fd47a5ec3c61?hl=en&
The requirement is listed in books online under the alter
table topic in the section alter column - the limitation is
from statistics generated by an explicit create statistics
statement. I think you also can hit issues if you have
hypothetical index left behind from the Index tuning wizard.
From books online:
The altered column cannot be:
Used in statistics generated by the CREATE STATISTICS
statement. First remove the statistics using the DROP
STATISTICS statement. Statistics automatically generated by
the query optimizer are automatically dropped by ALTER
COLUMN.
-Sue
On Tue, 13 Sep 2005 15:03:01 -0700, "sysbox27"
<sysbox27@.discussions.microsoft.com> wrote:
>Hi,
>anybody have a script or an idea on how to delete all stats in a db?
>while on the topic why do some stats (column I think) prevent column from
>being upgraded via alter table statement? I would have expected stats to be
>dropped as soon as column modified.
>Thanks.|||Thanks very much Sue.
"Sue Hoegemeier" wrote:
> Try the following post from Dan Guzman:
> http://groups.google.com/group/microsoft.public.sqlserver.server/msg/8dd9fd47a5ec3c61?hl=en&
> The requirement is listed in books online under the alter
> table topic in the section alter column - the limitation is
> from statistics generated by an explicit create statistics
> statement. I think you also can hit issues if you have
> hypothetical index left behind from the Index tuning wizard.
> From books online:
> The altered column cannot be:
> Used in statistics generated by the CREATE STATISTICS
> statement. First remove the statistics using the DROP
> STATISTICS statement. Statistics automatically generated by
> the query optimizer are automatically dropped by ALTER
> COLUMN.
> -Sue
> On Tue, 13 Sep 2005 15:03:01 -0700, "sysbox27"
> <sysbox27@.discussions.microsoft.com> wrote:
> >Hi,
> >anybody have a script or an idea on how to delete all stats in a db?
> >while on the topic why do some stats (column I think) prevent column from
> >being upgraded via alter table statement? I would have expected stats to be
> >dropped as soon as column modified.
> >Thanks.
>

No comments:

Post a Comment