如何在存储过程中调用存储过程?大家给个例子?
======
create proc kk
as
begin
exec jj --jj为存储过程名
end
=======
create table test(id int,name varchar(10))
insert into test select 1,'AAAA'
insert into test select 2,'BBBB'
go
create procedure sp_test1(@count int output)
as
select @count=count(*) from test
go
create procedure sp_test2
as
begin
declare @count int
exec sp_test1 @count output
select @count
end
go
exec sp_test2
go
--输出结果
/*
2
*/
drop procedure sp_test2,sp_test1
drop table test
go
---------------------
1,存储过程
create proc dbo.SPd_test
as
begin
return 2;
end
2,得到return 的值
DECLARE @RC int
EXEC @RC = [eppoo].[dbo].[SPd_test]
DECLARE @PrnLine nvarchar(4000)
PRINT ''''存储过程: eppoo.dbo.SPd_test''''
SELECT @PrnLine = '''' 返回代码 = '''' + CONVERT(nvarchar, @RC)
PRINT @PrnLine