Warm tip: This article is reproduced from stackoverflow.com, please click
sql sql-server

Get column names of all tables in SQL

发布于 2020-03-29 21:01:57

I need a query to generate column names (and it's type if possible) of all tables in database.

Is there any simple way?

Questioner
Dignity Dignity
Viewed
38
Gordon Linoff 2020-01-31 18:43

You can use INFORMATION_SCHEMA.COLUMNS:

select c.*
from INFORMATION_SCHEMA.COLUMNS c;

This has name, type, and a lot of other information for all tables in a database -- note, not on a server but in a database.