Adding Filegroups and creating tables on that filegroup

  • Hi,

    I need to add secondary file group to each database and create a table assigned to that filegroup in each database. I am looking for commands to do this so that I could write an application to do this automatically instead of going to each database and doing it. Please let me know.

    Thanks,

    Sridhar.

  • Here is a sample of the code I used to create a new File Group, a new file, and then add a table to that File Group.

    ALTER DATABASE [DELTA2] ADD FILEGROUP [SECONDARY]

    GO

    ALTER DATABASE [DELTA2] ADD FILE(NAME = N'FILE_2',

    FILENAME = N'C:\FILE_2_Data.NDF' ,

    SIZE = 1, FILEGROWTH = 10%)

    TO FILEGROUP [SECONDARY]

    GO

    CREATE TABLE TBL_NEW

     ( FIELD_1 INTEGER NOT NULL,

     FIELD_2 VARCHAR(255) NULL) ON [SECONDARY]

    GO

  • Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply