INSERT INTO在存储过程中不起作用

时间:2015-03-05 20:53:45

标签: sql

我编写了这个检查某些条件的过程,然后根据数据运行INSERT或UPDATE。但是,由于某种原因,INSERT不会执行。

IF @sid = ''
    BEGIN
        INSERT INTO Book_Art (Sub_ID, Art_IDs, P_ID) VALUES (@Sub_ID,@art_id,@P_ID)
    END
ELSE IF @aids = ''
    BEGIN
        SET @comma = ''
        UPDATE Book_Art SET Art_IDs = + @aids + @comma + @art_id WHERE Sub_ID =  @Sub_ID AND P_ID = @P_ID
    END
ELSE
    BEGIN
        SET @comma = ','
        UPDATE Book_Art SET Art_IDs = + @aids + @comma + @art_id WHERE Sub_ID =  @Sub_ID AND P_ID = @P_ID
    END
END

1 个答案:

答案 0 :(得分:1)

取代以下内容:

IF @sid = '' 

使用:

IF @sid is null