Sql几个不经常用,但是又功能强大的语句

fn_listextendedproperty (返回数据库对象的扩展属性值)详情

语法:

 fn_listextendedproperty (
      { default | 'property_name' | NULL }
    , { default | 'level0_object_type' | NULL }
    , { default | 'level0_object_name' | NULL }
    , { default | 'level1_object_type' | NULL }
    , { default | 'level1_object_name' | NULL }
    , { default | 'level2_object_type' | NULL }
    , { default | 'level2_object_name' | NULL }
    )

 如:select * from fn_listextendedproperty(null, 'schema', 'dbo', 'table', 'Jobs', 'Column', 'Job_id')

 

 

SQL_VARIANT_PROPERTY(返回有关 sql_variant 值的基本数据类型和其他信息,说是这么说,其实不止用于sql_variant值) 详情

语法

SQL_VARIANT_PROPERTY ( expression , property )

如:

SELECT  p.name AS [PropertyName],
  p.value AS [PropertyValue],
  SQL_VARIANT_PROPERTY(p.value,'BaseType') AS [PropertyBaseType],
  SQL_VARIANT_PROPERTY(p.value,'MaxLength') AS [PropertyMaxLength],
  SQL_VARIANT_PROPERTY(p.value,'Precision') AS [PropertyPrecision],
  SQL_VARIANT_PROPERTY(p.value,'Scale') AS [PropertyScale]
FROM fn_listextendedproperty(null, 'schema', 'dbo', 'table', 'Jobs', 'Column', 'Job_id') p;
 

posted @ 2010-12-14 17:49  HUGO.CM  阅读(184)  评论(0编辑  收藏  举报