create table #tmp
(
total int
)
declare @total nvarchar(100)
declare @sql varchar(4000)set @sql='
insert into #tmp select count(1) from xyza where portid=1'select @total=@total from #tmp
exec(@sql)
print @total
(
total int
)
declare @total nvarchar(100)
declare @sql varchar(4000)set @sql='
insert into #tmp select count(1) from xyza where portid=1'select @total=@total from #tmp
exec(@sql)
print @total
declare @str Nvarchar(500)set @str='select @total=count(0) from tab_1 where '+@str
exec sp_executesql @str,'@total int out',@total outselect @total
else
set @sqls = 'select @a=count(*) from [' + @BtoStr0 + ']'exec sp_executesql @sqls,N'@a int output',@num output