Wednesday, March 16, 2011

Getting Column Names from a Table in SQL Server


-- All table info
SELECT *
FROM INFORMATION_SCHEMA.Columns
WHERE TABLE_NAME = 'tblName'



-- Column Info
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.Columns
WHERE TABLE_NAME = 'tblName'

No comments:

Post a Comment