Declare @TableName Varchar(100)
Set @TableName = 'TableName'
Declare @Count int
Declare @SqlString Nvarchar(1000)
Set @SqlString = 'Select @OutCount = Count(*) From ' +@TableName
Exec sp_Executesql @SqlString, N'@OutCount Int Output', @OutCount = @Count Output