Thursday, May 24, 2018

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



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)?


Answer



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'


Can be made over all these DB objects:




No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...