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

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




相关文章:

  • 2021-11-12
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-01-16
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2022-01-16
  • 2021-08-03
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-01-11
  • 2021-09-23
相关资源
相似解决方案