Discard changes made to SQL Server database setup

I am not sure if this question can be asked here or serverfault. I was wondering ... Is there a way to quickly undo the changes made by SQL Server 2005 Tuning Advsor other than restoring from a backup?

+3
source share
3 answers

There is a way, if you did not rename it, usually created generated Database Tuning Advisor objects have a prefix _dta

enter image description here

to view them by completing this request

Indexes FOR

SELECT        
*
FROM            
sys.indexes where name like '_dta%'

FROM Stats

SELECT
*
FROM 
sys.stats where name like '_dta%'

And from there, I think, you will find out what items need to be dropped

+4
source

UNDO , DROP . .

, , , - . . , UNDO . - , . , UNDO , , .

  SELECT object_name(object_id) tablename,
         name indexname,
         nullif(name,name) statsname,
         STATS_DATE(object_id, index_id) lastupdated
    from sys.indexes
   where STATS_DATE(object_id, index_id) >= dateadd(hh,-1,getdate())
  -- and name like '_dta%'
   union all
  SELECT object_name(object_id) tablename,
         nullif(name,name) indexname,
         name statsname,
         STATS_DATE(object_id, stats_id) lastupdated
    from sys.stats
   where STATS_DATE(object_id, stats_id) >= dateadd(hh,-1,getdate())
  -- and name like '_dta%'
order by lastupdated desc

, . , - , , . and name like '_dta%' , - , ?

+2

psuedo-dynamic SQL, SQL-, . , _dta.

SELECT
'drop index' + OBJECT_NAME (object_id) + '. [' + name + ']'
sys.indexes '_dta%'

, , .

,

SELECT
'drop index' + OBJECT_NAME (object_id) + '. ['+ name +'] 'FROM
sys.stats where type name is' _dta%'

+1
source

Source: https://habr.com/ru/post/1762307/


All Articles