SQL SERVER – Get Column Names

A very common question, I keep on getting is how to get column names for a particular tables. Well, it is pretty straightforward and easy to do. Let us see various methods to do it.

SQL SERVER - Get Column Names getcolnames-800x188

Method 1:

FROM sys.columns 
WHERE object_id = OBJECT_ID('TableName')

Method 2:


Method 3:

SELECT  SCHEMA_NAME(o.schema_id) SchemaName, o.Name, c.Name
FROM     sys.columns c 
         JOIN sys.objects o ON o.object_id = c.object_id 
WHERE    o.type = 'U' AND c.name = N'TableName'
ORDER BY o.Name, c.Name

Method 4:

sp_help N'TableName'

Well, that’s it for today. Let me know what are your thoughts about this blog post. Let me know if you want me to create a video on this topic. I hope you like this blog post about how to Get Column Names of Table.

Here are my few recent videos and I would like to know what is your feedback about them. You can subscribe to my youtube channel here. Recently I have written a book about blogging. The name of the book is How to Become Successful Blogger and it is available to download via Kindle eBook over here. Let me know what you think about it.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL Column, SQL Scripts, SQL Server, SQL Stored Procedure
Previous Post
SQL SERVER – Fix: There is already an object named ‘MyFirstTable’ in the database
Next Post
SQL SERVER – Find Untrusted Foreign Key

Related Posts

3 Comments. Leave new

  • one more Method ti get it
    SP_Columns TableName

  • Another option is the shortcut to highlight the name of your table in the SSMS IDE and hit Alt + F1. To my understanding that executes Method 4 (sp_help ‘object_name’) for you.

  • I have a personal preference for method #2 since I know I can easily refer to information_schema intellisense from SSMS. But for everyday use, I just drag/drop the columns from the table/column folder to the query editor.


Leave a Reply