Requête pour répertorier toutes les tables contenant une colonne spécifique avec SQL Server 2005

StackOverflow https://stackoverflow.com/questions/31566

  •  09-06-2019
  •  | 
  •  

Question

Question comme indiqué dans le titre.

Était-ce utile?

La solution

http://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/

USE AdventureWorks
GO
SELECT 
    t.name AS table_name
    ,SCHEMA_NAME(schema_id) AS schema_name
    ,c.name AS column_name
FROM 
    sys.tables AS t
    INNER JOIN sys.columns c 
        ON t.OBJECT_ID = c.OBJECT_ID
WHERE 
    c.name LIKE '%EmployeeID%'
ORDER BY 
    schema_name
    ,table_name;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top