我的 SQL 语句有什么问题?
ALTER PROCEDURE prGetDocById
@Nbr varchar(100),
@Type uniqueidentifier,
@TotalRecord int output
AS
BEGIN
IF(@Type is null)
BEGIN
(
SELECT @TotalRecord = COUNT(Category) FROM Document where Nbr = @Nbr and
Type = (case when @Type IS not null then @Type else null end)
SELECT * from Document
)
end
else
begin
(
...
)
end
end
它给了我这个错误:
消息 156,级别 15,状态 1,过程 prGetDocById,第 12 行
关键字“SELECT”附近的语法不正确。
消息 102,级别 15,状态 1,过程 prGetDocById,第 13 行
')' 附近的语法不正确。
消息 102,级别 15,状态 1,过程 prGetDocById,第 19 行
')' 附近的语法不正确。
我想从IF
语句开始,也需要返回输出,所以我的语句中会有两个选择语句。
如果我没有IF
声明就写它,一切都很好。