Display the field name and description of the data table by creating a stored procedure
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'