sp_executesql为什么不能得到数据集的值?急!!!!!!!!!!!!

sonkey 2005-01-26 08:26:08
execute sp_executesql @SelectSQL,--返回一个整数
N'@cnt int output',
@cnt output

Select @cnt--打印出来为NULL
请问怎么得到这个值呢?
...全文
120 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sonkey 2005-01-26
  • 打赏
  • 举报
回复
多谢无声
问题解决了
didoleo 2005-01-26
  • 打赏
  • 举报
回复
假设为:Select 4

declare @SelectSQL nvarchar(4000),@cnt int
set @SelectSQL='select @cnt=4'
execute sp_executesql @SelectSQL,--返回一个整数
N'@cnt int output',
@cnt output
select @cnt

--------------
4
sonkey 2005-01-26
  • 打赏
  • 举报
回复
假设为:Select 4
mschen 2005-01-26
  • 打赏
  • 举报
回复
你的@selectSQL的内容是什么?
didoleo 2005-01-26
  • 打赏
  • 举报
回复
--给个例子你
declare @s nvarchar(4000),@i int
set @s='select @i=count(1) from orders'
exec sp_executesql @s,N'@i int output',@i output
select @i

34,593

社区成员

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

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