请帮忙看看我的sql语句有什么错误!
来源:百度知道 编辑:UC知道 时间:2024/07/05 11:27:36
declare @month int
declare @year int
declare @sql varchar (1000)
set @month=9
set @year=2008
select case
when @month in (1,2,4,6,8,9,11) then @sql='a'
when @month in (5,7,10,12) then 1
when @month=3 and ((@year % 400 = 0)or(@year % 4 = 0) and (@year % 100 <> 0)) then 2
-- else print @month
end
请帮忙更正!
then后面是不是不能跟赋值语句阿?
declare @year int
declare @sql varchar (1000)
set @month=9
set @year=2008
select case
when @month in (1,2,4,6,8,9,11) then @sql='a'
when @month in (5,7,10,12) then 1
when @month=3 and ((@year % 400 = 0)or(@year % 4 = 0) and (@year % 100 <> 0)) then 2
-- else print @month
end
请帮忙更正!
then后面是不是不能跟赋值语句阿?
declare @month int
declare @year int
declare @sql varchar (2)
set @month=9
set @year=2008
select @sql=case
when @month in (1,2,4,6,8,9,11) then 'a'
when @month in (5,7,10,12) then '1'
when @month=3 and ((@year % 400 = 0)or(@year % 4 = 0) and (@year % 100 <> 0)) '2'
-- else print @month
end
试试这样行不行
CASE最后要带END CASE的吧
你加上试试、。
看不懂,学习中。帮你顶下。
不过你应该说下在那个数据库里使用的。
不能跟的话你先赋好值不就玩事了
你不能在cage语句中赋值给@sql啦,你最好是用if语句比较好写,