存储过程是一系列SQL语句的组合
定义变量
declare @变量 数据类型
declare @UserID int
declare @UserName varchar(20)
打印某个变量的值
select @变量
select @UserID
条件语句:
if 条件
begin
end
if 条件
begin
end
else 条件
begin
end
变量赋值:
set @UserID=1
--给@UserID变量赋值为某个表中的数据
--想查询帐号名=XXX 的用户ID
select @UserID=UserID from AccountsInfo where accounts='移动网络'