大家帮忙看上T-SQL
大家帮忙看下T-SQL
消息 156,级别 15,状态 1,第 35 行
关键字 'CASE' 附近有语法错误。
消息 102,级别 15,状态 1,第 43 行
'@allCount' 附近有语法错误。
------解决方案--------------------
------解决方案--------------------
多写个t吧
------解决方案--------------------
declare @userClass varchar(20) --用户功臣级别
declare @allCount int
set @allCount=@tcount+@rcount
select @userClass=(CASE when @allCount<10 then '新手上路'
when @allCount between 10 and 20 then '侠客'
when @allCount between 21 and 30 then '骑士'
when @allCount between 31 and 40 then '精灵王'
when @allCount between 41 and 50 then '光明使者'
when @allCount > 50 then '法老' END)
print @uname+'帖数总计:'+rtrim(@allcount)+'贴 功臣级别:'+@userClass
declare @userClass varchar(20) --用户功臣级别
declare @allCount int
set @allCount=@tcount+@rcount
CASE
when @allCount<10 then @userClass='新手上路' when @allCount between 10 and 20 then @userClass='侠客'
when @allCount between 21 and 30 then @userClass='骑士'
when @allCount between 31 and 40 then @userClass='精灵王'
when @allCount between 41 and 50 then @userClass='光明使者'
when @allCount > 50 then @userClass='法老'
END
消息 156,级别 15,状态 1,第 35 行
关键字 'CASE' 附近有语法错误。
消息 102,级别 15,状态 1,第 43 行
'@allCount' 附近有语法错误。
------解决方案--------------------
declare @userClass varchar(20) --用户功臣级别
declare @allCount INT
set @allCount=@tcount+@rcount;
SELECT @userClass = CASE --注意这里
when @allCount<10 then '新手上路'
when @allCount between 10 and 20 then '侠客'
when @allCount between 21 and 30 then '骑士'
when @allCount between 31 and 40 then '精灵王'
when @allCount between 41 and 50 then '光明使者'
when @allCount > 50 then '法老'
END
------解决方案--------------------
多写个t吧
------解决方案--------------------
declare @userClass varchar(20) --用户功臣级别
declare @allCount int
set @allCount=@tcount+@rcount
select @userClass=(CASE when @allCount<10 then '新手上路'
when @allCount between 10 and 20 then '侠客'
when @allCount between 21 and 30 then '骑士'
when @allCount between 31 and 40 then '精灵王'
when @allCount between 41 and 50 then '光明使者'
when @allCount > 50 then '法老' END)
print @uname+'帖数总计:'+rtrim(@allcount)+'贴 功臣级别:'+@userClass