How can I get column names from a table in SQL

I want to query the name of all columns of a table. I found how to do this in:

But I also need to know: how can this be done in Microsoft SQL Server (2008 in my case)?

Answer:

get column names You can obtain this information and much, much more by querying the Information Schema views.

This sample query:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = N'Customers'

get column names Can be made over all these DB objects:

See More: Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7
SQL Check if table exists
Add a column with a default value to an existing table in SQL

One thought on “How can I get column names from a table in SQL

Leave a Reply

Your email address will not be published. Required fields are marked *