您好,登錄后才能下訂單哦!
在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'
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。