Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
babuman
Starting Member
5 Posts |
Posted - 2011-06-28 : 16:14:00
|
If this is the wrong forum for SMO Questions, I apologize. I couldn't find a more suitable forum for my question.I am writing a User Interface to view all the SMO.View objects and display the components involved in it. One of the issues I am having is to retrieve all the tables involved in an existing View. I can see all the columns involved. But the Column.Parent only points to the View itself. I need the names of the tables for each column including their alias if any. I can see this information in the View.TextBody. I can also see the column information by calling View.EnumColumns(). But I can't find the table information anywhere. I am sure this information is stored somewhere in the view or elsewhere on the database. Can someone help me with this please? I really appreciate it.Babu. |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-06-28 : 16:32:34
|
INFORMATION_SCHEMA.VIEW_TABLE_USAGEhttp://msdn.microsoft.com/en-us/library/ms173869(v=sql.100).aspx |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-06-28 : 17:48:05
|
I take back what I said above. You are trying to find the SMO class/method that exposes it. I don't have an answer for that. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-28 : 18:05:17
|
I'm pretty sure there's an SMO method to execute SQL, the best thing is to use that to run sunita's query and display the results. |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-06-28 : 22:14:34
|
I played around with it, and I think (think) that all you can do is take the columns, then loop through the tables.columns collection and match 'em.Could be wrong. Also, not sure if the TableViewbBase object exposes this. The view object does not.Tend to agree with Rob on this. |
 |
|
|
|
|