How to get column names from a table in SQL Server?

Asked

Viewed 34,544 times

9

Table Languages:

inserir a descrição da imagem aqui

How to select the Column Names of this table?

The result would be:

"Ididiome", "Acronym", and "Language".

2 answers

13

Select INFORMATION_SCHEMA.COLUMNS asking for the column COLUMN_NAME. In INFORMATION_SCHEMA.COLUMNS you have information about all columns for all tables of a database schema.

Query:

SELECT COLUMN_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'NomedaTabela'

Sqlfiddle

12


Browser other questions tagged

You are not signed in. Login or sign up in order to post.