惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
V
V2EX
MongoDB | Blog
MongoDB | Blog
量子位
J
Java Code Geeks
GbyAI
GbyAI
Attack and Defense Labs
Attack and Defense Labs
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cloudbric
Cloudbric
Recorded Future
Recorded Future
月光博客
月光博客
Help Net Security
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
Scott Helme
Scott Helme
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
G
Google Developers Blog
T
Troy Hunt's Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
InfoQ
S
SegmentFault 最新的问题
G
GRAHAM CLULEY
C
Check Point Blog
Project Zero
Project Zero
有赞技术团队
有赞技术团队
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
P
Privacy International News Feed
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Full Disclosure
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Hacker News: Front Page
S
Secure Thoughts
罗磊的独立博客
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园_首页
宝玉的分享
宝玉的分享
C
Cybersecurity and Infrastructure Security Agency CISA

博客园 - 俩醒叁醉

ASP.NET MVC 4 WebAPI. Support Areas in HttpControllerSelector SQL2000安装问题(转) sql server 2008安装需要一直重启。但重启后又没有达到效果。 为数据库中所有的用户数据表生成分页存储过程 __doPostBack方法解析 如何在三个月掌握三年的经验(转载&&笔记) jQuery Ajax的使用 JQuery资源网站 Cookie跨域、虚拟目录 深入分析跨域cookie的问题 CnBlogsDotText使用实例 轻松搭建博客平台-开源ASP.NET 博客Subtext 的安装 表达式目录树(源MSDN) Web 2.0 编程思想:16条法则 Control Adapter 以下代码提供查询数据库中是否存在某个值 URL Routing MVC Controllers和Forms验证 CSharp——Lambda 表达式
SQL 2005 字段备注获取
俩醒叁醉 · 2009-08-25 · via 博客园 - 俩醒叁醉

  实际开发中经常为数据字段备注而烦恼,为此写了如下存储过程,一方便查看数据库备注信息.

 1  
 2 create proc [dbo].[GenerateDataDictionaryByTableName]
 3 @tableName  nvarchar(255)
 4 as
 5 begin
 6 --获取数据表名
 7 declare  @tableid int
 8 declare mycursor Cursor
 9 for select object_id from sys.objects where type='U' and  name<>'dtproperties' and name LIKE '%'+ @tableName+'%'
10 --获取字段名称、标识、字段序号、占用字节数、小数位数、允许空等
11 open mycursor
12 fetch next from mycursor into @tableid
13 while(@@fetch_status=0) 
14 begin 
15     SELECT object_name(@tableid) AS 表名,VALUE AS 表说明 FROM sys.extended_properties 
16     WHERE NAME='MS_Description' AND MAJOR_ID=@tableid AND MINOR_ID=0;
17     select 
18         col.colorder 字段序号,
19         col.name 字段名,
20         t.name 类型,
21         col.length 占用字节数,
22         COLUMNPROPERTY(col.id,col.name,'PRECISION') as 长度,
23         isnull(COLUMNPROPERTY(col.id,col.name,'Scale'),0) as 小数位数,
24         (case when 
25             (SELECT count(*)
26                 FROM sysobjects
27                 WHERE (name in
28                     (SELECT name
29                         FROM sysindexes
30                         WHERE (id = col.id) 
31                             AND (indid in
32                                     (SELECT indid
33                                      FROM sysindexkeys
34                                      WHERE (id = col.id) AND (colid in
35                                             ( SELECT colid
36                                               FROM syscolumns
37                                               WHERE (id = col.id)
38                                                     AND (name = col.name)
39                                               ))
40                                      )
41                                   )
42                    )) AND
43                    (xtype = 'PK')
44               )>0 
45          then '' else '' end) 主键,
46         (case when COLUMNPROPERTY(col.id,col.name,'IsIdentity')=1 then ''else '' end) 标识,
47         (case when col.isnullable=1 then ''else '' end) 允许空,
48         isnull(expro.[value],'') AS 字段说明
49     from sys.syscolumns as col
50     left join sys.systypes as t on col.xtype = t.xusertype
51     left join sys.extended_properties as expro on col.id=expro.major_id AND col.colid = expro.minor_id
52     where id = @tableid 
53     fetch next from mycursor into @tableid
54 end
55 close mycursor
56 deallocate mycursor 
57 end

  在需要查看指定表描述时,输入如下语句:

exec [GenerateDataDictionaryByTableName] N'T_INTE_'

该存储过程会搜索当前数据库中表名包含传入的参数字符串,并返回符合条件的所有表的备注信息。如下返回形如: