web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Victoria Yudin / How to find all SQL tables ...

How to find all SQL tables with a column name

Victoria Yudin Profile Picture Victoria Yudin 22,769

Often I need to find all the tables in Dynamics GP that have a particular column or search for all columns where I only have a partial column name. Over the years I have seen lots of different code to accomplish this, so this is nothing new. But I am asked about this enough that I thought I would share the code I use:

SELECT
    TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME in
   (SELECT name
    FROM sysobjects
    WHERE xtype = 'U')
and COLUMN_NAME like '%xxxx%' -- replace with yours
ORDER BY COLUMN_NAME, TABLE_NAME

Just replace the xxxx with what you are looking for and run.


Filed under: SQL Server Tagged: SQL code

This was originally posted here.

Comments

*This post is locked for comments