MSSQL: Find out which tables have a field by name

Sunday, August 31, 2008 15:35
Category: Technology

I found myself working on a database in which relations exist only in theory, as it was not enough there should be about a hundred tables in which some of them have so many other fields. At one point I had to know what tables exist in the field a certain name, solution:

SELECT sc. [Name] AS column_name, so. [Name] AS table_name
FROM syscolumns sc
INNER JOIN sysobjects so ON = sc.id so.id
WHERE sc. [Name] LIKE '%% bocado_do_nome_do_campo'

Related Posts with Thumbnails

Tags: , ,

One Response to "MSSQL: Find out which tables have a field by name"

  1. Mário Nogueira says:

    August 31st, 2008 at 16:53

    Oracle would be simpler: a view user_tab_columns (or dba_tab_columns for all objects) has all the information ;)

Leave your comment