John Sutor wrote:
Does anyone know what objects to use to query a SQL database to get back
all of the tables and then be able to get information on the tables and
column information (name, datatype, max length etc...)
*** Sent via Developersdex http://www.developersdex.com ***
Each database contains a sysobjects and syscolumns system tables. With a
joins on a few other system tables you can get the information direct
from the database. E.g.
USE your_database
GO
SELECT tbl.name, col.name, typ.name, col.length, col.isnullable,
col.collation
FROM sysobjects tbl
INNER JOIN syscolumns col
ON tbl.id = col.id
INNER JOIN systypes typ
ON col.xtype = typ.xtype
WHERE tbl.xtype = 'u' and typ.name != 'sysname'
ORDER BY tbl.name, col.colorder
--
Regards
JTC ^..^