Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL query for a database scheme

Tags:

sql

sql-server

In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?

like image 513
Dan Avatar asked Aug 06 '08 15:08

Dan


People also ask

What is a SQL database schema?

What is Schema in SQL? In a SQL database, a schema is a list of logical structures of data. A database user owns the schema, which has the same name as the database manager. As of SQL Server 2005, a schema is an individual entity (container of objects) distinct from the user who constructs the object.

How do I find the database schema version in SQL Server?

Establishing Schema Version 1.0. 0.0. This is done by executing the ALTER_01_00. sql listed above (with database name set appropriately). Only after this script has been executed can we start using the versioning stored procedures.

How do I print a SQL schema?

In Management Studio, Click the "+" next to your database expanding the objects below it and click on "Tables" Open the Tables detail view by selecting "View" -> "Object Explorer Details" from the menu. Now select all tables (on the right hand side in the object details)


1 Answers

The following query will bring back a unique list of tables where Column_Name is equal to the column you are looking for:

SELECT Table_Name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE Column_Name = 'Desired_Column_Name'
GROUP BY Table_Name
like image 141
GateKiller Avatar answered Oct 22 '22 14:10

GateKiller