sql server - Use TSql to find the original table that a column within a view came from -


if create view such as:

create view view1 select table1.column1 table1 

is there way find table1 given name view1. it's easy enough find columns within view1 querying sys.columns object_id equal object_id of view name sys.objects how can tell underlying table column within view came from?

execute sp_describe_first_result_set @browse_information_mode = 1. return result set underlying table name , column name of each view column along other meta-data. source information null view columns derived expressions other meta-data (e.g. data type information) included.

exec sp_describe_first_result_set       @tsql=n'select * dbo.yourview;'     , @params = null     , @browse_information_mode = 1; 

note sp_describe_first_result_set introduced in sql server 2012 not work in prior versions of sql server.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -