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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upendra Pratap ShahiPosted Aug 18, 2015, 2:52 AM
Upendra Pratap ShahiPosted Aug 18, 2015, 3:03 AM
Ankit ShuklaPosted Aug 18, 2015, 3:01 AM
Ankit ShuklaPosted Aug 18, 2015, 2:47 AM
Upendra Pratap ShahiPosted Aug 18, 2015, 1:38 AM
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]
Sumit JoshiPosted Aug 18, 2015, 1:22 AM
Manas MohapatraPosted Aug 18, 2015, 1:14 AM