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