Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Display the field name and description of the data table by creating a stored procedure

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In the development of winform program, when it comes to the combined query of a table, the field name and description of the table will be extracted from the database, so that the user can choose the query. It is more troublesome to use statements in C #, and it is more convenient to write to the stored procedure.

USE [schoolDB] GO/* Object: StoredProcedure [dbo]. [sp_showcolumn] Script Date: 06 * / SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER proc [dbo]. [sp_showcolumn] @ tablename varchar (30) as select c.name as field name P.value as explains 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.nameplate description 'left join systypes t on c.xusertype=t.xusertypewhere o.typewritten description u' and o.name=@tablename

Sql statements that query for more information:

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.nameplate description 'left join systypes t on c.xusertype=t.xusertypewhere o.typewriter' and o.nameplate description cdxmain'

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report