gpt4 book ai didi

sql - 如何使 SELECT NEXT VALUE 在 SQL Server 中工作?

转载 作者:行者123 更新时间:2023-12-02 14:30:01 26 4
gpt4 key购买 nike

我在尝试让以下内容在 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 中正常工作?

最佳答案

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

关于sql - 如何使 SELECT NEXT VALUE 在 SQL Server 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18531354/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com