【发布时间】:2012-04-23 02:42:15
【问题描述】:
我的 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语句开头,也需要返回输出,所以我的语句中会有两个select语句。
如果我不写IF 语句,一切都OK。
【问题讨论】:
标签: sql