通过创建存储过程显示数据表的字段名和说明
在winform程序开发中,涉及到对某个表的组合查询时会到数据库中提取表的字段名和说明,以便于用户选择查询,在C#中使用语句比较麻烦,写到存储过程中就比较方便了。
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了东营免费建站欢迎大家使用!
USE [schoolDB] GO /****** Object: StoredProcedure [dbo].[sp_showcolumn] Script Date: 06/03/2016 16:45:26 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[sp_showcolumn] @tablename varchar(30) as select c.name as 字段名,p.value as 说明 from sysobjects o left join syscolumns c on o.id=c.id left join sys.extended_properties p on p.major_id=c.id and p.minor_id=c.colid and p.name='MS_Description' left join systypes t on c.xusertype=t.xusertype where o.type='u' and o.name=@tablename
查询更多信息的sql语句:
select o.name as tableName,c.name as columnName,t.name as columnType,p.value as columnDescription from sysobjects o left join syscolumns c on o.id=c.id left join sys.extended_properties p on p.major_id=c.id and p.minor_id=c.colid and p.name='MS_Description' left join systypes t on c.xusertype=t.xusertype where o.type='u' and o.name='cdxmain'
网站题目:通过创建存储过程显示数据表的字段名和说明
浏览地址:http://azwzsj.com/article/ijdgdd.html