(SQL statements) to find all tables have a column name in the database

First, the operating environment

  1. Database version: sql server 2012
  2. Test Database: Northwind, installation method, please refer to this article
    Northwind table structure

Second, query the database table INFORMATION_SCHEMA.COLUMNS

1. Create a new query, enter the following statement

SELECT 
	*
FROM 
	INFORMATION_SCHEMA.COLUMNS

View Results
Here Insert Picture Description
can be obtained from each table column names the figure
increased to filter conditions

SELECT 
	TABLE_NAME
FROM 
	INFORMATION_SCHEMA.COLUMNS
WHERE 
	COLUMN_NAME='CustomerID'

#“CustomerID”为要查询的列名字段

The results are as follows
Here Insert Picture Description

Published 62 original articles · won praise 68 · views 160 000 +

Guess you like

Origin blog.csdn.net/ZUFE_ZXh/article/details/86679983