• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
June's New World
知识和经验都是一点点积累的!现在努力也不晚,June加油!
博客园    首页    新随笔    联系   管理    订阅  订阅
存储过程里调用另一个存储过程的值

第一种:

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

posted on 2010-11-23 17:13  冬雨在路上  阅读(706)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3