Voici une requête simple pour obtenir tout cela :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ------------------------------- -- Nicolas SOUQUET - 13/12/2010 ------------------------------- SELECT S.name AS schema_name , T.name AS table_name , C.name AS column_name , C.column_id , TY.name AS data_type_name , CASE WHEN TY.name IN ('nchar', 'nvarchar') THEN C.max_length / 2 ELSE C.max_length END AS max_length FROM sys.schemas AS S INNER JOIN sys.tables AS T ON S.schema_id = T.schema_id INNER JOIN sys.columns AS C ON C.object_id = T.object_id INNER JOIN sys.types AS TY ON TY.system_type_id = C.system_type_id AND TY.system_type_id = TY.user_type_id WHERE 1 = 1 --AND S.name = 'dbo' --AND T.name = 'maTable' --AND C.name = 'maColonne' ORDER BY T.name, C.column_id |
ElSüket