How to get all the column names in a data table

xiaoxiao2021-03-06  14

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

You can modify it yourself, you can put it directly in JSP to execute select name from syscolumnswhere (id = (select id from sysobjects where (id = Object_id ('YourTableName'))) Order by Colid

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

New Post(0)