Find all tables containing column with specified name - MS SQL Server

sql query to find tables with a specific value in any column
sql query to find column name in all tables
how to find table name from column value in sql server
find all references to a column in sql server
find all tables with column name oracle
sql query to find column name in database
how to find table name from column name in sql server
query to get column names of a table in sql server

Search Tables:

SELECT      c.name  AS 'ColumnName'
            ,t.name AS 'TableName'
FROM        sys.columns c
JOIN        sys.tables  t   ON c.object_id = t.object_id
WHERE       c.name LIKE '%MyName%'
ORDER BY    TableName
            ,ColumnName;

Search Tables & Views:

SELECT      COLUMN_NAME AS 'ColumnName'
            ,TABLE_NAME AS  'TableName'
FROM        INFORMATION_SCHEMA.COLUMNS
WHERE       COLUMN_NAME LIKE '%MyName%'
ORDER BY    TableName
            ,ColumnName;

Find all tables containing column with specified name, How do I find a specific column in a SQL Server database? Only one thing which was common was that each column name contained the word GUID in it. Here is the script which you can run for your database and Find All Tables Containing Specific Column Name. SELECT Table_Name, Column_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = 'YOUR_DATABASE' AND COLUMN_NAME LIKE '%YOUR_COLUMN%'


We can also use the following syntax:-

select * from INFORMATION_SCHEMA.COLUMNS 
where COLUMN_NAME like '%clientid%' 
order by TABLE_NAME

How to find all the tables in MySQL with specific column names in , How do I get a list of column names in SQL Server? With our basic knowledge of both catalog views and the LIKE statement, we are now equipped to lookup all the tables in our system that contain a particular column name: SELECT sys.columns.name AS ColumnName, tables.name AS TableName FROM sys.columns JOIN sys.tables ON sys.columns.object_id = tables.object_id WHERE sys.columns.name = 'ColumnName'


SQL SERVER, How do I find the same column in another table in SQL? Use this Query to search Tables & Views: SELECT COL_NAME AS 'Column_Name', TAB_NAME AS 'Table_Name'. FROM INFORMATION_SCHEMA.COLUMNS. WHERE COL_NAME LIKE '%MyName%'. ORDER BY Table_Name, Column_Name; • Schema.COLUMNS - the name of the schema of fetched column. • Table_Name - the name of the fetched table.


select  
        s.[name]            'Schema',
        t.[name]            'Table',
        c.[name]            'Column',
        d.[name]            'Data Type',
        c.[max_length]      'Length',
        d.[max_length]      'Max Length',
        d.[precision]       'Precision',
        c.[is_identity]     'Is Id',
        c.[is_nullable]     'Is Nullable',
        c.[is_computed]     'Is Computed',
        d.[is_user_defined] 'Is UserDefined',
        t.[modify_date]     'Date Modified',
        t.[create_date]     'Date created'
from        sys.schemas s
inner join  sys.tables  t
on s.schema_id = t.schema_id
inner join  sys.columns c
on t.object_id = c.object_id
inner join  sys.types   d
on c.user_type_id = d.user_type_id
where c.name like '%ColumnName%'

This here will give you a little extra information about the schema, tables and columns that you may or may not choose to use extra conditions in your where clause to filter on. For example, if you only wanted to see the fields which must have values add

and c.is_nullable = 0

You could add other conditionals, I also added the columns in the select clause in this vertical manner so it was easy to reorder, remove, rename, or add others based on your needs. Alternately you could search for just tables by using T.Name. Its very customisable.

Enjoy.

SQL SERVER, SQL SERVER – Query to Find Column From All Tables of Database return all the tables containing specific column along with their schema name. If you want to find all the column name from your database run following script. Find all tables containing column with specified name within linked server. Find all tables containing column with specified name - MS SQL Server Hot Network Questions What is the origin of the fears of racism associated with facial recognition technology?


This should work:

SELECT name 
FROM sysobjects 
WHERE id IN ( SELECT id 
              FROM syscolumns 
              WHERE name like '%column_name%' )

Finding Tables that Contain a Specific Column in SQL Server, During the recent Comprehensive Database Performance Health Check, I was asked if I know any trick to identify column with a Specific Name  You can use ApexSQL Search, it's a free SSMS and Visual Studio add-in and it can list all objects that reference a specific table column. It can also find data stored in tables and views. You can easily filter the results to show a specific database object type that references the column Disclaimer: I work for ApexSQL as a Support Engineer


Find tables with specific column name in SQL Server database , Find all tables in the database which contain a specific column in SQL Server through Before we get into how to extract all tables with a particular name, we should the values of a specified column ) match a formatted string of characters​. Below is a copy of an answer to a similar question I already provided here (Search for a string in an all the tables, rows and columns of a SQLL Server DB) ’d suggest you find yourself a 3rd party tool for this such as ApexSQL Search (there are probably others out there too but I use this one because it’s free).


How to write a query to find all tables in a db that have a specific , Find all tables containing column with specified name - MS SQL Server? Is it possible to query for table names which contain columns being  Using SQL Server 2008, say I have a table called testing with 80 columns and I want to find a value called foo.. I can do: SELECT * FROM testing WHERE COLNAME = 'foo' Is it possible I can query all 80 columns and return all the results where foo is contained in any of the 80 columns?


Find all tables containing column with specified name - MS SQL Server · Ask Question. Asked 8 years, 10 months ago. Active 6 months ago. Viewed 2.0m times. I did use the following Statement to find all tables that could possibly hold binary-data/files. SELECT table_name FROM INFORMATION_SCHEMA.TABLES T WHERE T.TABLE_CATALOG = 'MyDatabase' AND EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS C WHERE C.TABLE_CATALOG = T.TABLE_CATALOG AND C.TABLE_SCHEMA = T.TABLE_SCHEMA AND C.TABLE_NAME = T.TABLE_NAME AND ( C.DATA_TYPE = 'binary' OR C.DATA_TYPE