1SELECT @ActualTableName = QUOTENAME( TABLE_NAME )
2FROM INFORMATION_SCHEMA.TABLES
3WHERE TABLE_NAME = @PassedTableName
4
5DECLARE @sql AS NVARCHAR(MAX)
6--SELECT @sql = 'SELECT COUNT(*) FROM [' + @ActualTableName + '];'
7
8-- changed to this
9SELECT @sql = 'SELECT COUNT(*) FROM ' + @ActualTableName + ';'
10
11EXEC(@SQL)