Quick query to dump table field name and type for data mapping document

SELECT

COLUMN_NAME AS [Field Name]

, (DATA_TYPE + CASE

WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL

THEN '(' + CONVERT(VARCHAR(20), CHARACTER_MAXIMUM_LENGTH) + ')'

ELSE ''

END

) AS [Field Type]

FROM

INFORMATION_SCHEMA.COLUMNS

WHERE

TABLE_NAME = 'SOME TABLE NAME'

SELECT

COLUMN_NAME AS [Field Name]

, (DATA_TYPE + CASE

WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL

THEN '(' + CONVERT(VARCHAR(20), CHARACTER_MAXIMUM_LENGTH) + ')'

ELSE ''

END

) AS [Field Type]

FROM

INFORMATION_SCHEMA.COLUMNS

WHERE

TABLE_NAME = 'SOME TABLE NAME'

Print | posted on Friday, July 12, 2013 9:38 AM

Feedback

No comments posted yet.

Your comment:





 

Copyright © Kevin Shyr

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski