Übersicht aller Spalten; inkl. Constraints, Descriptions
-- Kann zum Reverse-Engineering verwendet werden
SELECTic.TABLE_CATALOG,ic.TABLE_SCHEMA,ic.TABLE_NAME,ic.ORDINAL_POSITION,ic.COLUMN_NAME,UPPER(ic.DATA_TYPE)ASDATA_TYPE,CASEWHENic.DATA_TYPE='INT'THENNULLELSECOALESCE(ic.CHARACTER_MAXIMUM_LENGTH,ic.NUMERIC_PRECISION)ENDASLENGHT1,CASEWHENic.NUMERIC_SCALE=0THENNULLELSEic.NUMERIC_SCALEENDASLENGHT2,ic.COLUMN_DEFAULT,CASEWHENic.IS_NULLABLE='YES'THENNULLELSEic.IS_NULLABLEENDASIS_NULLABLE,CASEWHENidc.seed_valueISNULLTHENNULLELSECONCAT(CONVERT(VARCHAR(10),idc.seed_value),',',CONVERT(VARCHAR(10),idc.increment_value))ENDAS[IDENTITY],iku.CONSTRAINT_NAME,itc.CONSTRAINT_TYPE,ep.[Value]AS[MS_Description]FROMinformation_schema.columnsicINNERJOINsys.columnsscONOBJECT_ID(QUOTENAME(ic.table_schema)+'.'+QUOTENAME(ic.table_name))=sc.[object_id]ANDic.column_name=sc.nameLEFTOUTERJOINsys.identity_columnsidcONsc.[object_id]=idc.[object_id]ANDidc.name=ic.column_nameLEFTOUTERJOINsys.extended_propertiesepONsc.[object_id]=EP.major_idANDsc.[column_id]=EP.minor_idANDep.name='MS_Description'ANDep.class=1LEFTOUTERJOINinformation_schema.key_column_usageikuONiku.column_name=ic.column_nameANDiku.table_name=ic.table_nameANDiku.table_schema=ic.table_schemaANDiku.table_catalog=ic.table_catalogLEFTOUTERJOINinformation_schema.table_constraintsitcONitc.table_name=iku.table_nameANDitc.constraint_name=iku.constraint_nameWHEREic.table_schemaLIKE'%%'ANDic.table_nameLIKE'%%'ORDERBYic.table_catalog,ic.table_schema,ic.table_name,ic.ordinal_position;