declare @sql nvarchar(2000)
declare @cou int
declare @id varchar(20)
set @id=''
set @sql='select @count=count(*) from emp where id=@id'
exec sp_executesql @sql, N'@count int out,@id varchar(20)', @cou out
,@id
print @cou
@cou接收 @count传出的值
declare @sql nvarchar(2000)
declare @cou int
declare @id varchar(20)
set @id=''
set @sql='select @count=count(*) from emp where id=@id'
exec sp_executesql @sql, N'@count int out,@id varchar(20)', @cou out
,@id
print @cou
@cou接收 @count传出的值