Use a variable for table name [duplicate]
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: how do find the number of rows in a table when the table name is in a variable? I need to find tables in a SQL Server database (2000) that contain one value for a column. I can use the following query to output a list of possible candidate tables containing my_column : SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'my_column' What I would like to get at, is the following pseudo