我有来自存储过程的返回值。但是当我将该值用于另一个select
时,它并没有给我任何东西。我只能更改我在下面解释的代码部分,但我不能更改任何现有的表和任何现有的存储过程。所以,请查看我的代码,并给我一些建议,我缺少什么或我做错了什么。我觉得这可能是type
问题,或者我不确定。存储过程不使用输出,只需从表中选择一个id。
谢谢!
我的代码:
declare @id int
exec @id = stored_proc
print (@id) -- it prints 21 which means stored procedure is returning a value
select type_name(@id) -- I was just curious to see the type and it shows 'void type'
select *
from table
where id = @id -- it doesn't return anything
set @id = 21
select type_name(@id) -- I was again curious to see type and here it shows 'NULL'
select *
from table
where id = @id -- it returns the row with an id of 21