Get columns of a table SQL SERVER

Using this query, you can get the list of columns of SQL Table using INFORMATION_SCHEMA.COLUMNS.

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tblCustomer'
 

We can also use the ORDINAL_POSITION method for order by and to select the specific columns of a table according to their position
 

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tblCustomer' and ORDINAL_POSITION between 1 and 11
ORDER BY ORDINAL_POSITION

Related Alrticles

FREE!!! Registration