复制代码 代码如下:
CREAT PROCEDURE tester
AS
BEGIN
SET NOCOUNT ON;
DECLARE @userId varchar(50)
DECLARE @count int
SET @count = 0
SELECT @count = count(*) FROM UserService_User WHERE Account like '%111%'
WHILE @count > 0
BEGIN
SELECT @userId = Id FROM UserService_User WHERE Account like '%111%'
exec UserService_RemoveUserByUserId @userId
SET @count = @count -1
END
END
2、循环体中 UserService_RemoveUserByUserId 是一个存储过程的名称,@userId为该存储过程的参数,如果有多个参数,使用“,”分开就可以了,这也是存储过程调用另一个存储过程的一种方法。
新闻热点
疑难解答