Back
How would I return the column names of a table using SQL Server 2008? i.e. a table contains these columns- id, name, address, country and I want to return these as data.
If you are using 2008 version, try using the code given below:
USE [Database Name]SELECT COLUMN_NAME,* FROM INFORMATION_SCHEMA.COLUMNSWHERE TABLE_NAME = 'YourTableName' AND TABLE_SCHEMA='YourSchemaName'
USE [Database Name]
SELECT COLUMN_NAME,*
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'YourTableName' AND TABLE_SCHEMA='YourSchemaName'
31k questions
32.8k answers
501 comments
693 users