create procedure sp_aa
(
@where varchar(8000)= ' ',--条件
@sqlstr varchar(8000)=null,
@total varchar(50) output
)
AS
set @sqlstr= 'select '[email protected]+ '=count(id) from aa '[email protected]
exec(@sqlstr)
[email protected],表中有记录的
------解决方案--------------------
create procedure sp_aa
(
@where varchar(8000)= ' ',--条件
@sqlstr nvarchar(4000)=null,
@total varchar(50) output
)
AS
set @sqlstr= 'select @total=count(id) from sysobjects '[email protected]
exec sp_executesql @sqlstr,N '@total varchar(50) output ',@total output
declare @total varchar(50)
exec sp_aa ' ',NULL,@total output
print @total