我正在尝试为序列创建动态起始编号,但它不接受变量即。@START_SEQ
为START WITH
. 请考虑以下代码:-
CREATE PROCEDURE [dbo].[SP_RESET_SEQ]
AS
DECLARE @START_SEQ INT =0;
BEGIN
SET @START_SEQ = (SELECT MAX(USER_ID)+1 FROM MASTER_USER);
IF OBJECT_ID('SEQ_USER_ID') IS NOT NULL
DROP SEQUENCE [dbo].[SEQ_USER_ID]
CREATE SEQUENCE [dbo].[SEQ_USER_ID]
AS [bigint]
START WITH @START_SEQ
INCREMENT BY 1
MINVALUE 1
MAXVALUE 99999999
CACHE
END