当前位置: 代码迷 >> Sql Server >> 怎么重 批处理中 返回值
  详细解决方案

怎么重 批处理中 返回值

热度:293   发布时间:2016-04-27 15:12:31.0
如何重 批处理中 返回值?
declare   @count   int   --保存查询条数
exec( "select   count(*)   from   t1 ")


现在我想把这个求出的记录条数   返回给外部定义的   @count   这个变量   如何做啊?
大虾指点下



------解决方案--------------------
use pubs
go

declare @count int --保存查询条数
declare @sql nvarchar(4000)
set @sql= 'select @count=count(*) from titles '
exec sp_executesql @sql, N '@count int output ', @count output
select @count

--result
-----------
18

(1 row(s) affected)
  相关解决方案