Sequence的当前值作为存储过程的默认参数

时间:2015-08-27 06:27:44

标签: sql sql-server

我有一个sql存储过程,它由两个参数组成。我需要将Sequence的当前值设置为一个参数的默认值。 因此,当我为参数添加默认值时,它会给我以下错误。

Msg 102, Level 15, State 1, Procedure sp_GET_TransformationSummary, Line 8
Incorrect syntax near '('.
Msg 156, Level 15, State 1, Procedure sp_GET_TransformationSummary, Line 11
Incorrect syntax near the keyword 'AS'.

这是我的代码..

ALTER PROCEDURE [dbo].[sp_GET_TransformationSummary]
@AreaCode           AS NVARCHAR(MAX),
@SyncId             AS INT = (SELECT CONVERT(INT, CURRENT_VALUE) FROM SYS.SEQUENCES WHERE name = 'SQ_COMMON')

AS
BEGIN
SET NOCOUNT ON;

SELECT * FROM TABLE_NAME
WHERE Area= @AreaCode AND SyncId = @SyncId;

END

有没有办法做到这一点?

我需要将{{1>} SQ_COMMON 序列作为默认值。

0 个答案:

没有答案