Saturday, October 24, 2009

Query to get all column names from database table in SQL Server.

SELECT COLUMN_NAME,Data_Type+'('+convert(varchar,character_maximum_length)+')'as DataType

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_NAME = 'Your Table Name'

ORDER BY ORDINAL_POSITION

No comments:

Post a Comment