Kevin Bowker
2006-02-01 15:14:53 UTC
I've automated defragging my indexes with a stored procedure, but can't
capture the results of the defrag into a table. How can I go about this?
I've tried:
Declare @sql varchar(1000)
Select @sql = 'DBCC INDEXDEFRAG(''SOSManager'',''tmpKeys'',''PK_tmpKeys'')'
Insert Into maint_IXDEFRAG (PagesScanned, PagesMoved, PagesRemoved)
exec(@sql)
but I get the following error:
Cannot perform a IndexDefrag operation inside a user transaction. Terminate
the transaction and reissue the statement.
Ideas?
capture the results of the defrag into a table. How can I go about this?
I've tried:
Declare @sql varchar(1000)
Select @sql = 'DBCC INDEXDEFRAG(''SOSManager'',''tmpKeys'',''PK_tmpKeys'')'
Insert Into maint_IXDEFRAG (PagesScanned, PagesMoved, PagesRemoved)
exec(@sql)
but I get the following error:
Cannot perform a IndexDefrag operation inside a user transaction. Terminate
the transaction and reissue the statement.
Ideas?