How to create a temporary table by specifying file groups?

I am creating a version control table for a history operation, but I want to specify a separate group of files, such as FG_Historyfor a temporary table.

How to change the following query:

CREATE TABLE [dbo].[ExpenseCenter]
(
    [ExpenseCenterId] [tinyint] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](200) NOT NULL,
    [SysStartTime] datetime2 (2) GENERATED ALWAYS AS ROW START,
    [SysEndTime] datetime2 (2) GENERATED ALWAYS AS ROW END,
    PERIOD FOR SYSTEM_TIME (SysStartTime, SysEndTime), 

    CONSTRAINT [PK_ExpenseCenter] 
        PRIMARY KEY CLUSTERED ([ExpenseCenterId] ASC)
                    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
                          IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
                          ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [FG_INDEX],
    CONSTRAINT [UK_ExpenseCenterName] 
        UNIQUE NONCLUSTERED ([Name] ASC)
                    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
                          IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
                          ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [FG_INDEX]
) ON [FG_DATA]
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = history.ExpenseCenterHistory))
GO

I would be grateful if anyone could help me.

+4
source share
1 answer

If I understand, you want the main table to be in one file group and in the archive in another file group. You can try to run the "Drop and Create to" script through the object explorer for the history table and indicate which filegroup you want the clustered index to be in.

+4
source

Source: https://habr.com/ru/post/1654959/


All Articles