存储过程里调用另一个存储过程的值
第一種:
USE [WMS]
GO
DECLARE?@return_value int
EXEC?@return_value = [dbo].[Sys_GetSysNo]
??@NoCode = N'D001'
SELECT?'Return Value' = @return_value
GO
?
第二種:創建一個臨時表
create proc GetUserName
as
begin
??? select 'UserName'
end
Create table #tempTable (userName nvarchar(50))
insert into #tempTable(userName)
exec GetUserName
select #tempTable
--用完之后要把臨時表清空
drop table #tempTable--需要注意的是,這種方法不能嵌套
第三種:
DECLARE @return_status INT
DECLARE @cmdText nvarchar(4000)--nvarchar 很重要這個地方
SET @cmdText='SELECT @return_status=COUNT(0) FROM '+@tableNameAdd+' WHERE '+@whereField +'='+''''+@Ops+'''';???
execute sp_executesql @cmdText,N'@return_status int out',@return_status out;
print @return_status
轉載于:https://www.cnblogs.com/JuneZhang/archive/2010/11/23/1885667.html
總結
以上是生活随笔為你收集整理的存储过程里调用另一个存储过程的值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 未完成的控件
- 下一篇: 城市统计年鉴数据查询