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

How to add, modify and delete field instructions in SQL Server database

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

SQL Server database how to add modify delete field description, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

SQLServer database field description of how to add, modify and delete

1. Query field descriptions for two tables

SELECTt. [name] AS [table name], c. [name] AS [field name], cast (ep.[ value] asvarchar) AS [field description] FROMsys.tablesAStINNERJOINsys.columnsAScONt.object_id=c.object_idLEFTJOINsys.extended_propertiesASepONep.major_id=c.object_idANDep.minor_id=c.column_idWHEREep.class= 1andt.[ name] = 'table2' and c. [name] in (' table2 field', 'table2 field') orc. [name] in ('table1 field 'table1 field')

two。 Add the name of the field

EXECsys.sp_addextendedproperty@name=N'MS_Description',@value=N' field description', @ level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name=N' table name', @ level2type=N'COLUMN',@level2name=N' field name'GO

SQLServer database field description of how to add, modify and delete

3. Modify the name of the field

BEGINTRANSACTIONGODECLARE@vsql_variantSET@v=N' description message 'EXECUTEsys.sp_updateextendedpropertyN'MS_Description',@v,N'SCHEMA',N'dbo',N'TABLE',N' table name, name of the field named' GOCOMMIT'

4. Query database field information and types

Selecta.nameaszdname,a.length,b.nameaszdtypefromsyscolumnsa,systypesb,sysobjectscwherea.xtype=b.xtypeanda.id=c.idandc.name='table'-- did not filter the system field information selecta.namerea.accounthreb.namefromsyscolumnsaptyesb.xtypeanda.objectscscwherea.xtype.xtypeanda.roomc.idandc.namefields, tablefields, ANDB.namemade fields, filtering system field information selecta.name,a.length,b.namefromsyscolumnsa,systypesb,sysobjectscwherea.xtype=b.xtypeanda.id=c.idandc.name='table'andcharindex ('sysname'') B.name) = 0mi-system field information is filtered.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Database

Wechat

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

12
Report