November 17, 2004 at 2:23 pm
The following SQL:
Alter table Holidays
Alter column Country char(50) not null
is failing with this message:
Server: Msg 5074, Level 16, State 8, Line 1
The statistics 'aaaatttt' is dependent on column 'Country'.
Server: Msg 4922, Level 16, State 1, Line 1
ALTER TABLE ALTER COLUMN Country failed because one or more objects access this column.
I can fix this by doing this first:
drop statistics Holidays.aaaatttt
I have 100's of databases I need to do a similar thing to. I cannot find a way to get the name of the statistics for a column in a SQL script. It would take forever to read the error and execute the drop command.
Is there a way to get the name? Or even drop all statistics?
John.
November 17, 2004 at 10:04 pm
write a script to Go through the list of all objects you wish to ALTER
Get the list of their stats into a temp table
insert into #temp exec sp_helpstats @objname = 'Orders'
build a dynamic query to call DROP STATISTICS on each of the statistics.
November 18, 2004 at 10:04 am
Thanks, that is just what I was looking for.
John.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply