第一种:

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

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案