Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a list of column names output by a view

Status
Not open for further replies.

SmileyConspiracy

Technical User
Feb 17, 2003
13
GB
I need to Create a list of column names output by a view. Not a problem using sysobjects and syscolumns. The problem is that I also need to get the tablename for where each column comes from. i.e. if I had the following as a view

Select Person.DomicileId, Person.PersonId from Person Inner Join Domicile on Person.DomicileId = Domicile.DomicileId

I would want the following returned

TableName ColumnName
----------- ---------------------
Person DomicileId
Person PersonId

I've tried using the INFORMATION_SCHEMA.VIEW_COLUMN_USAGE view, but this returns both DomicileIds because one is used in the join! Help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top