Select Columns of a View

steventnorris picture steventnorris · Jun 29, 2012 · Viewed 75.8k times · Source

I'm attempting to select the column names of a view in a similar way as selecting from information_schema.columns.

I can't seem to find a way to do this. Has anyone else done this before or know if it is even possible?

Answer

Ghost picture Ghost · Jun 29, 2012

information_schema.columns.Table_name (at least under Sql Server 2000) includes views, so just use

SELECT * FROM information_schema.columns WHERE table_name = 'VIEW_NAME'