How can I get column names from a table in SQL Server

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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

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

Answers

http://msdn.microsoft.com/en-us/library/aa933204%28SQL.80%29.aspx http://msdn.microsoft.com/en-us/library/aa933204%28SQL.80%29.aspx

This sample query:

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

Can be made over all these DB objects:

- CHECK_CONSTRAINTS
- COLUMN_DOMAIN_USAGE - COLUMN_PRIVILEGES
- COLUMNS
- CONSTRAINT_COLUMN_USAGE
- CONSTRAINT_TABLE_USAGE
- DOMAIN_CONSTRAINTS
- DOMAINS
- KEY_COLUMN_USAGE
- PARAMETERS
- REFERENTIAL_CONSTRAINTS
- ROUTINES
- ROUTINE_COLUMNS
- SCHEMATA
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
- TABLES
- VIEW_COLUMN_USAGE
- VIEW_TABLE_USAGE
- VIEWS

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/1054984/how-can-i-get-column-names-from-a-table-in-sql-server

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils