我正在尝试根据一个条件更新数据集,然后检索所有更新的行。VS 一直告诉我在我的 OUTPUT 子句附近有一个不正确的语法错误,但我没有发现任何错误。我只是想弄清楚如何使用“输出”,所以这可能是我犯的一个非常愚蠢的错误,但没有看到。
这个 OUTPUT 子句有什么问题(语法上)?
CREATE PROCEDURE [dbo].[GetInitialSessionNotifications]
@CurrentSessionId bigint
AS
DECLARE @tempTable table(
id bigint NOT NULL,
[Type] nvarchar,
DocumentCommentID bigint,
AnnouncmentID int,
EventID int,
MeetingID int,
[Read] bit,
RecieverId int,
AnnouncmentCommentId bigint,
EventCommentId bigint,
MeetingCommentId bigint,
DateAndTime DateTime);
UPDATE Notifications SET SessionId = @CurrentSessionId
WHERE SessionId != @CurrentSessionId
OUTPUT INSERTED.id,
INSERTED.[Type],
INSERTED.DocumentCommentID,
INSERTED.AnnouncmentID,
INSERTED.EventID,
INSERTED.MeetingID,
INSERTED.[Read],
INSERTED.RecieverId,
INSERTED.AnnouncmentCommentId,
INSERTED.EventCommentId,
INSERTED.MeetingCommentId,
INSERTED.DateAndTime
INTO @tempTable;
SELECT id, [Type], DocumentCommentId, AnnouncmentID, EventID, MeetingID,
[Read], RecieverId, AnnouncmentCommentId, EventCommentId, MeetingCommentId, DateAndTime
FROM @tempTable;
返回 0