Sql 实用代码

查看表描述

SELECT
    ROW_NUMBER() OVER (ORDER BY A.name) AS No, A.name AS table_name, CONVERT(NVARCHAR(100),ISNULL(B.[value],'-')) AS table_description
FROM
       sys.tables A LEFT JOIN
       sys.extended_properties B ON (A.object_id = B.major_id AND B.minor_id=0)
WHERE A.name='Favorites'

查看表字段描述

SELECT
    B.name AS table_name, A.name AS column_name, c.name AS type_name, A.max_length AS type_length, D.value AS column_description
FROM
    sys.columns A JOIN
    sys.tables B ON A.object_id=B.object_id JOIN
    sys.types C ON A.user_type_id=C.user_type_id LEFT JOIN
    sys.extended_properties D ON A.object_id=D.major_id AND A.column_id=D.minor_id
WHERE B.name='Favorites'

你可能感兴趣的:(工具)