Tuesday, 17 May 2016

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

SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('dbo.yourTableName')


or

  SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
     TABLE_NAME  ='MyTable'
      AND
      TABLE_CATALOG='MyDBName'