I would like to output the result of the dynamic SQL into a variable called @Count but not sure what the syntax or even the code should like to accomplish this.
The code looks as follows:
declare @tab nvarchar(255) = 'Person.person'
declare @Count int
declare @SQL nvarchar(max) = 'select count(*) from '+ @tab
exec(@SQl)
select @Count
thank you