开发者

How to control returning value / table of a stored procedure

ALTER PROC SP_SampleInner
AS
SELECT COUNT(*) FROM TB_Whatever

Other procedure

ALTER RPROC SP_SampleOuter
AS
DECLARE @count int
EXEC @count = SP_SampleInner

IF @count > 0
BEGIN
SELECT 1
END
ELSE
BEGIN
SELECT 0
END

What I want is SP_SampleOuter returns more than one table because of EXEC SP_SampleInner (I think).开发者_如何学Go How could I control returning tables/values?


Try this approach:

ALTER PROC SP_SampleOuter
AS
DECLARE @count int
EXEC @count = SP_SampleInner

IF @count > 0
BEGIN
SELECT @count as Ctr,1
END
ELSE
BEGIN
SELECT @count as Ctr,0
END

Simply add the count variable as the first field you return


Use an output variable to send the count back.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜