Technical Article

Get information from tables

,

This script can be used when we can not obtain the data dictionary of a database

SELECT TAB.NAME AS NOMBRE_TABLA, 
COL.NAME AS NOMBRE_COLUMNA,


TIP.NAME AS TIPO_DATO,


COL.MAX_LENGTH AS TAMAO,


CASE 
WHEN COL.IS_NULLABLE = '0' THEN 'NO'


ELSE 'SI'


END AS ACEPTA_NULL,


EXT.VALUE AS DESCRIPCION
 
FROM SYS.TABLES TAB


INNER JOIN


SYS.COLUMNS COL ON TAB.OBJECT_ID = COL.OBJECT_ID


INNER JOIN


SYS.TYPES TIP ON TIP.USER_TYPE_ID = COL.USER_TYPE_ID


LEFT OUTER JOIN


SYS.EXTENDED_PROPERTIES EXT ON EXT.MAJOR_ID = TAB.OBJECT_ID AND COL.COLUMN_ID = EXT.MINOR_ID

Rate

1.25 (4)

You rated this post out of 5. Change rating

Share

Share

Rate

1.25 (4)

You rated this post out of 5. Change rating