how should i pass a table name into a stored proc 3f

Solutions on MaxInterview for how should i pass a table name into a stored proc 3f by the best coders in the world

showing results for - "how should i pass a table name into a stored proc 3f"
Jessica
10 Mar 2019
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)