Rebuild indexes on Filegroup

Vijay Kumar 2,031 Reputation points

How to rebuild all indexes on all tables in single file group in sql server 2016?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,264 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
{count} votes

Accepted answer
  1. CathyJi-MSFT 21,121 Reputation points Microsoft Vendor

    Hi @Vijay Kumar ,

    Try below T-SQL;

    AS FileGroupName,  
    AS TableName,  
    As IndexName,  
      'DBCC DBREINDEX("' + SCHEMA_NAME(st.schema_id) + '.' + + '", ' + QUOTENAME( + ')' AS ReIndexCommand  
    FROM sys.indexes si  
    INNER JOIN sys.tables st ON si.object_id = st.object_id  
    INNER JOIN sys.data_spaces sd ON si.data_space_id = sd.data_space_id  
       WHERE = 'filegroupname'  

    Quote from this similar thread REBUILD THE INDEXES BY FILE GROUP .

    If the response is helpful, please click "Accept Answer" and upvote it, thank you.

    0 comments No comments

0 additional answers

Sort by: Most helpful