在存储过程中,如何获得执行一条SQL语句Count统计返回的值?

powbcom 2006-10-19 09:38:37
注意,这条SQL语句是组合起来的declare @sql nvarchar(3000)
set @sql = 'Select Count(' + @Fields + ') from table'
如何在存储过程中执行@SQL得到返回的值?

...全文
248 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
powbcom 2006-10-19
  • 打赏
  • 举报
回复
谢谢
九斤半 2006-10-19
  • 打赏
  • 举报
回复
参考:

-- 参数输出

declare @sql nvarchar(4000),
@a int,
@b int
set @sql='select @aout=count(*),@bout=count(*) from master..sysdatabases'
exec sp_executesql @sql,N'@aout int output,@bout int output',@a output,@b output
print @a
print @b

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧