为何得不到输出参数?!在线等待高手指点.

clxxj 2003-08-22 03:10:56
如何输出@id
Create Procedure GetCount
@s nvarchar(50),@ID int output
as
begin
declare @sql nvarchar(1000)
set @sql=N'select @id = count(*) from vproduct where pname like '+@s+''
exec sp_executesql @sql,N'@id int output',@id output
end

GO

declare @aa int

exec getcount 'e',@id=@aa output

select @aa

...全文
25 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
clxxj 2003-08-22
  • 打赏
  • 举报
回复
真的是够复杂,搞到晕了.
结果已经可以得出!但对以下语句不很了解!sp_executesql?
exec sp_executesql @sql,N'@id int output',@id output
happydreamer 2003-08-22
  • 打赏
  • 举报
回复
Create Procedure GetCount
@s nvarchar(50),@ID int output
as
begin
declare @sql nvarchar(1000)
set @sql=N'select @id = count(*) from vproduct where pname like '''+@s+''''
exec sp_executesql @sql,N'@id int output',@id output
end

GO

declare @aa int

exec getcount 'e',@id=@aa output

select @aa
happydreamer 2003-08-22
  • 打赏
  • 举报
回复
Create Procedure GetCount
@s nvarchar(50),@ID int output
as
begin
declare @sql nvarchar(1000)
set @sql=N'select @id = count(*) from vproduct where pname like '''+@s+''''
exec sp_executesql @sql,N'@id int output',@id output
end

GO

declare @aa int

exec getcount 'e',@id=@aa output

select @aa
愉快的登山者 2003-08-22
  • 打赏
  • 举报
回复
Create Procedure GetCount
@s nvarchar(50),@ID int output
as
begin
declare @sql nvarchar(1000)
set @sql=N'select @id = count(*) from vproduct where pname like '''+@s+''''
exec sp_executesql @sql,N'@id int output',@id output
end

GO

declare @aa int

exec getcount 'e',@id=@aa output

select @aa

34,575

社区成员

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

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