9

以下を SQL Server で動作させるのに苦労しています。

CREATE TABLE table_X AS
    SELECT 
        NEXT VALUE FOR GROUP_A AS GROUP_ID, RISK_ID
    FROM 
        ( SELECT UNIQUE RISK_ID, FROM table_Y ) SS;

私は言われた:

"Incorrect syntax near the keyword 'SELECT'."
"Incorrect syntax near the keyword 'UNIQUE'."

正確には何が問題で、これを修正して動作させるにはどうすればよいSQL Serverですか?

4

3 に答える 3

18
CREATE TABLE Person
(
FirstName Varchar(50),
LastName Varchar(50)
);

/*
Insert Some Values Into Person
*/

CREATE SEQUENCE CountBy
    START WITH 1
    INCREMENT BY 1 ;

SELECT NEXT VALUE FOR CountBy OVER (ORDER BY LastName) AS ListNumber,
    FirstName, LastName
    INTO table_x
FROM Person
于 2013-08-30T11:20:59.193 に答える
2
SELECT 
    NEXT VALUE FOR GROUP_A AS GROUP_ID, SS.RISK_ID
INTO
    table_X 
FROM 
    ( SELECT DISTINCT RISK_ID FROM table_Y ) SS
于 2013-08-30T11:12:52.833 に答える
1

これを試してみてください -

IF OBJECT_ID ('dbo.table_X') IS NOT NULL
   DROP TABLE dbo.table_X

SELECT RISK_ID --, ..... columns
INTO dbo.table_X
FROM ( 
    SELECT DISTINCT RISK_ID 
    FROM dbo.table_Y 
) SS

SELECT * 
FROM dbo.table_X
于 2013-08-30T11:13:22.570 に答える