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.