简体   繁体   中英

Create a table on specific filegroup in SQL Server?

So, this process I have is actually on SAS but the SQL syntax should be the same I need to put it on the filegroup STAGING_DATA_FG02, so I added as you can see below a line of code I thought would help but it is not reading it, is it the correct syntax?

CREATE TABLE DBO.TBL
AS
SELECT 
  input(&varFileDate, BEST22.) as FileDate  ,
  TRIM(SSN) as SSN              , 
  ExmDescription                , 
  Status                        ,
  ScaledScore                   ,
  ExamDate          
  FROM DBO.TBL_A
  ORDER BY SSN
  ON [STAGING_DATA_FG02] WITH (DATA_COMPRESSION = PAGE);

The syntax for creating a table from a query in SQL Server is select-into:

SELECT 
  input(&varFileDate, BEST22.) as FileDate  ,
  TRIM(SSN) as SSN              , 
  ExmDescription                , 
  Status                        ,
  ScaledScore                   ,
  ExamDate           
INTO DBO.TBL ON [STAGING_DATA_FG02]
FROM DBO.TBL_A

Note: The ON clause is only available in this syntax since SQL Server 2016 SP2. AFAIK, there is no way to use WITH (DATA_COMPRESSION = PAGE) with this syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM