|
Execute the following
Microsoft SQL Server T-SQL scripts in SSMS Query Editor to drop all stats on the Sales.SalesOrderDetail table.
-- SQL drop statistics - drop all stats on a table
-- SQL Server drop statistics - T-SQL cursor
USE AdventureWorks2008
GO
DECLARE curAllStats CURSOR FOR
SELECT Name
FROM sys.stats
WHERE object_id = object_id('Sales.SalesOrderDetail')
AND auto_created <> 0
DECLARE @StatName NVARCHAR(512)
OPEN curAllStats
FETCH NEXT FROM curAllStats
INTO @StatName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC( 'drop statistics Sales.SalesOrderDetail.' + @StatName)
FETCH NEXT FROM curAllStats
INTO @StatName
END -- WHILE
CLOSE curAllStats
DEALLOCATE curAllStats
GO
------------
-- T-SQL DBCC SHOW_STATISTICS - display statistics
DBCC SHOW_STATISTICS ("Sales.SalesOrderDetail", AK_SalesOrderDetail_rowguid);
------------
|