How to determine if a column of a view is derived or constant? How to determine if a column of a view is derived or constant? sql-server sql-server

How to determine if a column of a view is derived or constant?


Looks like there is no system view saves information you are looking for. You can find out derived column or constant column by parsing the view definition or by exception handling...not good, but didn't find other ways...


  1. Any columns come from the following aggregation functions, considered as derived column. AVG, COUNT,SUM,MIN,MAX,GROUPING,STDEV,STDEVP,VAR,VARP
  2. If the view definition contains following syntax, all columns considered as derived column. UNION, UNION ALL, CROSSJOIN, EXCEPT, INTERSECT
  3. The columns affected by GROUP BY, HAVING, DISTINCT, are also considered as derived column.

I don't think this cover all scenarios, but a start point to write the parser.