Using a Sequence
Consider this table:
CREATE TABLE [Events](
[EventID] [int] NULL,
<< Other columns >>
and this Sequence:
CREATE SEQUENCE [NewEventID]
AS [int]
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 2147483647
NO CACHE
and this Stored Procedure;
CREATE PROCEDURE [Insert_Event]
<< Parameters >>
AS
BEGIN
INSERT INTO
[Events]
(
EventID,
<< Other fields >>
)
VALUES
(
NEXT VALUE FOR NewEventID,
<< Other fields >>
)
END
GO
When I run this procedure, I get this error message:
NEXT VALUE FOR function cannot be used if ROWCOUNT option has been set, or the query contains TOP or OFFSET.
None of those conditions are true so why am I getting this error message?
Consider this table:CREATE TABLE [Events](
[EventID] [int] NULL,
<< Other columns >>and this Sequence:CREATE SEQUENCE [NewEventID]
AS [int]
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 2147483647
NO CACHE and this Stored Procedure;CREATE PROCEDURE [Insert_Event]
<< Parameters >>
AS
BEGIN
INSERT INTO
[Events]
(
EventID,
<< Other fields >>
)
VALUES
(
NEXT VALUE FOR NewEventID,
<< Other fields >>
)
END
GOWhen I run this procedure, I get this error message: NEXT VALUE FOR function cannot be used if ROWCOUNT option has been set, or the query contains TOP or OFFSET.None of those conditions are true so why am I getting this error message? Read More