SQLServer get all the column names in a particular table

Method a:
sp_help table

GO
Method two:
DECLARE @objid int, char objname @ (40)
SET @objname = 'table'
SELECT from the sysobjects WHERE ID = @objid ID = object_id (@objname)
SELECT 'Column_name' name = from syscolumns where id = @objid order by colid

method three:

the Select the name the fROM SYSCOLUMNS the Where the above mentioned id = Object_id ( 'table name')

four:

cross-database query a table column names are those (such a fine success!)
the SELECT name from database name .dbo.syscolumns where id = (select id from the database name .dbo.sysobjects where name = 'table')

Guess you like

Origin www.cnblogs.com/YZFHKMS-X/p/11756149.html