邀月周记

年轻的时候,多走走,走不动的时候,静下来写回忆录。3w@live.cn

获取SqlServer 2005中字段的备注信息--downmoon

上篇文章 中,介绍了如何获取SqlServer 2000中字段的备注信息
本文将介绍如何获取SqlServer 2005中字段的备注信息(downmoon)


Declare   @tblName   nvarchar ( 1000 )
                                    
set   @tblName = ' 表名 '
                                    
declare   @TblID   int
                                    
set   @TblID = ( select   [ object_id ]   as  tblID   from  sys.all_objects  where   [ type ]   = ' U '   and   [ name ] <> ' dtproperties '   and   [ name ] = @tblName
                                    
select  syscolumns.name  as  ColumnName,
                                    systypes.name 
as  ColumnType,
                                    syscolumns.length 
as  ColumnLength,
                                    (
SELECT     [ value ]   FROM   ::fn_listextendedproperty( NULL ' user ' ' dbo ' ' table ' object_name ( @TblID ),  ' column ' , syscolumns.name)   as  e  where  e.name = ' MS_Description ' as  ColumnDescription
                                                
from  sysColumns 
                                                
left   join  sysTypes  on  sysTypes.xtype  =  sysColumns.xtype  and  sysTypes.xusertype  =  sysColumns.xusertype 
                                                
left   join  sysobjects  on  sysobjects.id  =  syscolumns.cdefault  and  sysobjects.type = ' D '  
                                                
left   join  syscomments  on  syscomments.id  =  sysobjects.id 
                                    
where  syscolumns.id = @TblID




阅读更多
个人分类: SQL Utility 推荐
上一篇ASP.NET 2.0页面的中文编码问题--downmoon
下一篇根据SQL存储过程名取得存储过程内容(downmoon)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭