利用的扩展属性象access一样显示列的注释

来源:互联网 发布:伴游网站 源码 编辑:程序博客网 时间:2024/06/05 15:23
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
access的视图有个不错的功能-----设计列的注释,这可以让设计者清楚地看到每个列的意义。一般的sqlserver建表时没有这个功能,但是他有扩展属性,这个功能也不错,可以把注释写到这里面,然后把相应的结果作为rs返回到页面进行应用
我想,这在动态显示的table的列信息时候可能比较有用(记得好像以前论坛里也有人问到过)

具体方法如下:(也可以在EM,QA里面通过右击相应列---扩展属性,进行添加)

EXECsp_addextendedproperty'CRid','表示ID','user',dbo,'table','clientInfo','column',CRid
go
EXEC  sp_addextendedproperty'人名','显示客户姓名','user',dbo,'table','clientInfo','column',Rname
go

selectname,valuefrom::fn_listextendedproperty
(default,'user','dbo','table','clientInfo','column',default)

go

name          value
---------------------------------------------
CRid            表示ID
人名            显示客户姓名

这样就可以当作结果集用了

这里吧系统多表值函数fn_listextendedpeoperty简单说一下
查询的时候,因为是系统多表值函数所以前面必须有  ::
第1个是指定属性名称----如果用default或者NULL显示全部
第2-7个参数,可以参看sql的对象命名规则
如果用default也是指定全部

详细信息察看BOL

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击