So I have a view that has lots of "AS" stuff defined for different columns, e.g., some view columns simply map to one column in one physical table, some are defined by functions etc:
SELECT
dbo.LoanDataTable.F123 AS LoanOfficer,
dbo.udf_GetChannelTypeValueWithLoanOfficer(dbo.LoanDataTable.F123) AS ChannelType
In our application I want to be able to display on a web page the mapping of the view columns to their "AS" definitions, in a grid with two columns like so:
LoanOfficer dbo.LoanDataTable.F123
ChannelType dbo.udf_GetChannelTypeValueWithLoanOfficer(dbo.LoanDataTable.F123)
I have researched on stackoverflow:
Is there a way to retrieve the view definition from a SQL Server using plain ADO?
and
Suggestions on storing view meta in SQL Server 2008
All the first one does is retrieve the full text of the view definition, and no one ever answered the second one.
If I retrieve the full text of the view definition, such as seen at the top of this post, then I still need to somehow parse the text to extract the "AS" components. So my question is: is there a way to easily extract this information from SQL Server 2008 R2 and above, or if not, has someone already written some view-definition-parser code that will do this?