Geeks With Blogs

My Digital Life in Data Flow Data Warehouse, MDX, Cube, SSIS, BizTalk, SQL, XML, SSAS, SSRS, .NET

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'

Posted on Friday, July 12, 2013 9:38 AM Microsoft SQL - T-SQL , Microsoft SQL - DBA work | Back to top


Comments on this post: Quick query to dump table field name and type for data mapping document

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Kevin Shyr | Powered by: GeeksWithBlogs.net | Join free