Monday, 16 April 2012

Get column names from MSSQL

SELECT table_name=sysobjects.name,
         column_name=syscolumns.name,
         datatype=systypes.name,
         length=syscolumns.length
    FROM sysobjects 
    JOIN syscolumns ON sysobjects.id = syscolumns.id
    JOIN systypes ON syscolumns.xtype=systypes.xtype
   WHERE sysobjects.xtype='U'
ORDER BY sysobjects.name,syscolumns.colid
 
 
SELECT *
FROM information_schema.COLUMNS
WHERE table_name = 'EMPMAST'
 

No comments:

Post a Comment