StumbleUpon
Share on Facebook

Wednesday, May 9, 2007

Identify Column in All Tables

use AdventureWorks
Select * From sys.columns
select * from sys.tables

-- Select Columns From All Tables
select st.name, sc.name from sys.tables st, sys.columns sc
where st.object_id = sc.object_id

-- Select Specific Columns and their corresponding tables
select st.name, sc.name from sys.tables st, sys.columns sc
where st.object_id = sc.object_id
and sc.name = 'EmployeeID'

-- Select Specific Columns and their corresponding tables
select st.name, sc.name from sys.tables st, sys.columns sc
where st.object_id = sc.object_id
and sc.name = 'PurchaseOrderID'

No comments:

Related Posts Plugin for WordPress, Blogger...