Hi,
I need to print of a list which have all the fields name and datatype of all tables from a particular sql database in a order.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 17, 2015, 10:52 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Aug 17, 2015, 9:14 PM EDT
Sumit JoshiRank #1,252 · 1.4K reputationPosted Aug 17, 2015, 9:22 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 17, 2015, 9:38 PM EDT
SELECT QUOTENAME(SCHEMA_NAME(tb.[schema_id])) AS 'Schema'
,QUOTENAME(OBJECT_NAME(tb.[OBJECT_ID])) AS 'Table'
,C.NAME as 'Column'
,T.name AS 'Type'
,C.max_length
,C.is_nullable
FROM SYS.COLUMNS C INNER JOIN SYS.TABLES tb ON tb.[object_id] = C.[object_id]
INNER JOIN SYS.TYPES T ON C.system_type_id = T.user_type_id
WHERE tb.[is_ms_shipped] = 0
ORDER BY tb.[Name]
Ankit ShuklaRank #2,120 · 672 reputationPosted Aug 17, 2015, 10:47 PM EDT
Ankit ShuklaRank #2,120 · 672 reputationPosted Aug 17, 2015, 11:01 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 17, 2015, 11:03 PM EDT