Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Searching for a database field in the SQL Server Database Expand / Collapse
Author
Message
Posted Thursday, March 28, 2013 11:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 3, 2013 12:16 PM
Points: 4, Visits: 16
I am new to SQL Server and working on a new Data Base. I need to search the SQL Server database and list all Table names that have a Field I am looking for.

In Oracle I would do
SELECT column_name, Table_name FROM all_tab_columns
WHERE column_name = 'POS_TRANSACTION' ----Name_Of_Field from tables that I'm looking for

This will list all tables that have the field name.

How do I do this in SQL Server?

Thanks, Jim
Post #1436623
Posted Thursday, March 28, 2013 11:15 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:21 AM
Points: 12,896, Visits: 32,097
SQL is very similar, and there's two ways:

select TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME='POS_TRANSACTION'
--or
select OBJECT_NAME(object_id) As TableName, name As ColumnName from sys.columns where name ='POS_TRANSACTION'



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1436628
Posted Thursday, March 28, 2013 11:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 3, 2013 12:16 PM
Points: 4, Visits: 16
It works great. Thank you for the quick reply.
Post #1436631
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse