Few ways to get table columns in SQL Server:

Using sp_help

   1: EXEC sp_help 'SalesLT.Customer'

Using INFORMATION_SCHEMA

   1: SELECT 
   2:     * 
   3: FROM 
   4:     INFORMATION_SCHEMA.COLUMNS
   5: WHERE 
   6:     TABLE_CATALOG = 'SalesLT' 
   7:     AND TABLE_SCHEMA = 'SalesLT'
   8:     AND TABLE_NAME = 'Customer'

Using sys.columns DMV

   1: SELECT [name]
   2: FROM sys.columns
   3: WHERE OBJECT_NAME(object_id) = 'Customer'

 

Another userful tip:

Sometimes we need to specify column names in our T-SQL statements (INSERT/UPDATE/DELETE). It is very tedious to try and write them ourselves. Good thing in SSMS, you can drag the columns folder onto the code editor and this will list out all the columns in the table.

SQL Server Tip On Getting Table Columns

VN:F [1.9.22_1171]
Rating: 9.6/10 (8 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 3 votes)
Getting Table Columns in SQL Server, 9.6 out of 10 based on 8 ratings  
Be Sociable, Share!
  • Tweet