Home > Database > Mysql Tutorial > SQL2005读取所有表字段的备注

SQL2005读取所有表字段的备注

WBOY
Release: 2016-06-07 17:23:07
Original
984 people have browsed it

注:数据表所有字段说明其实都是都存放在sys.extended_properties这个表里面的,本文采用游标跟系统函数获取所有表字段说明文字 -

注:数据表所有字段说明其实都是都存放在sys.extended_properties这个表里面的,本文采用游标跟系统函数获取所有表字段说明文字

--声明变量
declare @TableName nvarchar(250) 
 
--声明一个游标mycursor,select语句中参数的个数必须要和从游标取出的变量名相同
declare mycursor cursor for select name from sys.tables  order by name
 
--打开游标
open mycursor
 
--从游标里取出数据赋值到我们刚才声明的变量中
fetch next from mycursor into @TableName
 
--判断游标的状态
--0 fetch语句成功   
---1 fetch语句失败或此行不在结果集中   
---2被提取的行不存在
while (@@fetch_status=0)
begin
 
--显示出我们每次用游标取出的值
--print '游标成功取出一条数据'
--print @TableName

SELECT * FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table', @TableName, 'column', default) where objname='spid';

--print 'EXEC dbo.aaa_lzq_getstr @TableName = '+@TableName
--用游标去取下一条记录
  fetch next from mycursor into @TableName
end
--关闭游标
close mycursor
--撤销游标
deallocate mycursor

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template