我猜一下你的意图case len(@propertyno) when '1' then @propertyno = 'XX00000+'@propertyno when '2' then @propertyno = 'XX0000+'@propertyno when '3' then @propertyno = 'XX000+'@propertyno when '4' then @propertyno = 'XX00+'@propertyno when '5' then @propertyno = 'XX0+'@propertyno when '6' then @propertyno = 'XX+'@propertyno else print 'propertyno数据出错' end 这段,改成 SELECT @propertyno= case len(@propertyno) when '1' then 'XX00000+'@propertyno when '2' then 'XX0000+'@propertyno when '3' then 'XX000+'@propertyno when '4' then 'XX00+'@propertyno when '5' then 'XX0+'@propertyno when '6' then 'XX+'@propertyno else print 'propertyno数据出错' end
下面的语句是有问题的,sql server的t-sql不支持case 选择结构,case 语句只能在一个sql语句中使用的 case len(@propertyno) when '1' then @propertyno = 'XX00000+'@propertyno when '2' then @propertyno = 'XX0000+'@propertyno when '3' then @propertyno = 'XX000+'@propertyno when '4' then @propertyno = 'XX00+'@propertyno when '5' then @propertyno = 'XX0+'@propertyno when '6' then @propertyno = 'XX+'@propertyno else print 'propertyno数据出错' end 是有问题的
SELECT @propertyno= case len(@propertyno) when '1' then 'XX00000+'@propertyno when '2' then 'XX0000+'@propertyno when '3' then 'XX000+'@propertyno when '4' then 'XX00+'@propertyno when '5' then 'XX0+'@propertyno when '6' then 'XX+'@propertyno else set @propertyno='propertyno数据出错' end
try this,declare @propertyno char(50) declare @prno intselect @propertyno=max(propertyno) from property where propertyno like 'hg%'
select @propertyno=dbo.F_Get_no(@propertyno)+1select @propertyno= case len(@propertyno) when 1 then 'XX00000+'@propertyno when 2 then 'XX0000+'@propertyno when 3 then 'XX000+'@propertyno when 4 then 'XX00+'@propertyno when 5 then 'XX0+'@propertyno when 6 then 'XX+'@propertyno else 'propertyno数据出错' endprint @propertyno
改成这样试试: declare @propertyno char (10) declare @prno int(3) select @propertyno=max(propertyno) from property where propertyno like 'hg%' SELECT @propertyno = dbo.F_Get_no(@propertyno)+1
select @propertyno = case len(@propertyno) when '1' then 'XX00000+'@propertyno when '2' then 'XX0000+'@propertyno when '3' then 'XX000+'@propertyno when '4' then 'XX00+'@propertyno when '5' then 'XX0+'@propertyno when '6' then 'XX+'@propertyno else 'propertyno数据出错' endprint @propertyno
when '1' then @propertyno = 'XX00000+'@propertyno
when '2' then @propertyno = 'XX0000+'@propertyno
when '3' then @propertyno = 'XX000+'@propertyno
when '4' then @propertyno = 'XX00+'@propertyno
when '5' then @propertyno = 'XX0+'@propertyno
when '6' then @propertyno = 'XX+'@propertyno
else
print 'propertyno数据出错'
end 这段,改成
SELECT @propertyno=
case len(@propertyno)
when '1' then 'XX00000+'@propertyno
when '2' then 'XX0000+'@propertyno
when '3' then 'XX000+'@propertyno
when '4' then 'XX00+'@propertyno
when '5' then 'XX0+'@propertyno
when '6' then 'XX+'@propertyno
else
print 'propertyno数据出错'
end
case len(@propertyno)
when '1' then @propertyno = 'XX00000+'@propertyno
when '2' then @propertyno = 'XX0000+'@propertyno
when '3' then @propertyno = 'XX000+'@propertyno
when '4' then @propertyno = 'XX00+'@propertyno
when '5' then @propertyno = 'XX0+'@propertyno
when '6' then @propertyno = 'XX+'@propertyno
else
print 'propertyno数据出错'
end
是有问题的
case len(@propertyno)
when '1' then 'XX00000+'@propertyno
when '2' then 'XX0000+'@propertyno
when '3' then 'XX000+'@propertyno
when '4' then 'XX00+'@propertyno
when '5' then 'XX0+'@propertyno
when '6' then 'XX+'@propertyno
else
set @propertyno='propertyno数据出错'
end
declare @prno intselect @propertyno=max(propertyno)
from property
where propertyno like 'hg%'
select @propertyno=dbo.F_Get_no(@propertyno)+1select @propertyno=
case len(@propertyno)
when 1 then 'XX00000+'@propertyno
when 2 then 'XX0000+'@propertyno
when 3 then 'XX000+'@propertyno
when 4 then 'XX00+'@propertyno
when 5 then 'XX0+'@propertyno
when 6 then 'XX+'@propertyno
else
'propertyno数据出错'
endprint @propertyno
declare @propertyno char (10)
declare @prno int(3)
select @propertyno=max(propertyno) from property where propertyno like 'hg%'
SELECT @propertyno = dbo.F_Get_no(@propertyno)+1
select @propertyno = case len(@propertyno)
when '1' then 'XX00000+'@propertyno
when '2' then 'XX0000+'@propertyno
when '3' then 'XX000+'@propertyno
when '4' then 'XX00+'@propertyno
when '5' then 'XX0+'@propertyno
when '6' then 'XX+'@propertyno
else 'propertyno数据出错'
endprint @propertyno
第二处:‘end ’附近有语法错误。 如果去掉“=”第一处错误还是报"关键字‘CASE’附近有语法错误”