2个回答
2017-09-27
展开全部
SQL Server中声明变量
declare @a int
declare @b int
declare @c int
declare @d int
declare @str int
set @str=0
while @str<=9999
begin
set @a=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),1,1) as int)
set @b=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),2,1) as int)
set @c=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),3,1) as int)
set @d=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),4,1) as int)
if (@a*7+@b*9+@c*10+@d*5+222)%11=3
begin
print ('a='+cast(@a as varchar)+' b='+cast(@b as varchar)+' c='+cast(@c as varchar)+' d='+cast(@d as varchar))
end
set @str=@str+1
end
declare @a int
declare @b int
declare @c int
declare @d int
declare @str int
set @str=0
while @str<=9999
begin
set @a=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),1,1) as int)
set @b=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),2,1) as int)
set @c=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),3,1) as int)
set @d=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),4,1) as int)
if (@a*7+@b*9+@c*10+@d*5+222)%11=3
begin
print ('a='+cast(@a as varchar)+' b='+cast(@b as varchar)+' c='+cast(@c as varchar)+' d='+cast(@d as varchar))
end
set @str=@str+1
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
检查一下声明变量语句的位置,看对不对。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询