SQL SERVER中变量声明的命令是什么
展开全部
declare @变量名 类型
比如给你写个例子,declare的那些都是生明变量,set是给变量赋值
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询