|
|
|
Click here to copy the following block |
DECLARE @TableName sysname DECLARE @indid int DECLARE cur_tblfetch CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_type = 'base table' OPEN cur_tblfetch FETCH NEXT FROM cur_tblfetch INTO @TableName WHILE @@FETCH_STATUS = 0 BEGIN DECLARE cur_indfetch CURSOR FOR SELECT indid FROM sysindexes WHERE id = OBJECT_ID (@TableName) and keycnt > 0 OPEN cur_indfetch FETCH NEXT FROM cur_indfetch INTO @indid WHILE @@FETCH_STATUS = 0 BEGIN SELECT 'Derfagmenting index_id = ' + convert(char(3), @indid) + 'of the ' + rtrim(@TableName) + ' table' IF @indid <> 255 DBCC INDEXDEFRAG (0, @TableName, @indid) FETCH NEXT FROM cur_indfetch INTO @indid END CLOSE cur_indfetch DEALLOCATE cur_indfetch FETCH NEXT FROM cur_tblfetch INTO @TableName END CLOSE cur_tblfetch DEALLOCATE cur_tblfetch |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|