StumbleUpon
Share on Facebook

Monday, September 5, 2011

How to get Column Names of All Tables in a database through SQL Query / SysTables in SQL Server 2008

How to list all tables and each table, loop through each column using SQL query

It is not uncommon to get the list of all column names from all available tables; at times some valuable information peeps out when one researches it. The following query will get you exactly that


select sys.syscolumns.name as ColumnName, sys.sysobjects.name as TableName from sys.syscolumns,sys.sysobjects where sys.sysobjects.id = sys.syscolumns.id



3 comments:

ankush said...

it does not work in MySQL

milzed said...

Has to be run in db2 mainframe. Not data warehouse, works just fine for me

milzed said...

Only works in dp2 mainframe not in data warehouse. Works fore just fine.

Related Posts Plugin for WordPress, Blogger...