How to remove all the column names in SQLServer

zhaozj2021-02-16  50

How to get all the column names of a data table as follows: First get the systemID of the data table from the SystemObject system table, and then all column names in the data table are obtained in the SYSCOLUMN table. SQL statement is as follows: declare @objid int, @ objname char (40) set @objname = 'tablename'select @objid = id from sysobjects where id = object_id (@objname) select' Column_name '= name from syscolumns where id = @objid ORDER by colid

Is it too simple? Oh, but often used.

转载请注明原文地址:https://www.9cbs.com/read-27021.html

New Post(0)