十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
在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'