这可能是一个愚蠢的语法错误,但我只是继续阅读我的程序,但我无法弄清楚我的错误在哪里.
消息156,级别15,状态1,行41
关键字"FOR"附近的语法不正确.
这是我的代码:
alter procedure LockReservation as
DECLARE @edition_id tinyint, @stockid tinyint;
DECLARE @creservation CURSOR FOR select edition_id from reservation where (date_fin - GETUTCDATE()) <= 12;
open creservation;
while @@fetch_status = 0
BEGIN
fetch creservation into @edition_id;
DECLARE @cstock CURSOR
FOR select id from stock where edition_id = @edition_id;
open cstock;
while @@fetch_status = 0
BEGIN
fetch cstock into @stockid;
select stock_id from location where location.stock_id = @stockid and archivage = 0
if @@rowcount = 0
BEGIN
insert into …Run Code Online (Sandbox Code Playgroud) 我想将一个新列添加到已包含数据的现有表中.列应为NOT NULL.因为我想设置默认值.但是,当我这样做时抛出以下异常:"'''附近的语法不正确
ALTER TABLE Semester ADD SIDNew uniqueidentifier NOT NULL
CONSTRAINT DF_SIDNew DEFAULT '00000000-0000-0000-0000-000000000000' FOR SIDNew
Run Code Online (Sandbox Code Playgroud)
我已经看过如何设置现有列的默认值 和关键字'FOR'附近的错误语法,但它们都没有帮助我.