Hi folks,

 

I have a SQL statement for SQL Server 2000 which I can’t get quite right:

 

SELECT o.name as TABLE_NAME,

            c.name AS COLUMN_NAME, c.length AS COLUMN_LENGTH, c.isnullable AS IS_NULLABLE, c.colstat AS COLUMN_STATUS,

            t.name AS COLUMN_TYPE

FROM sysobjects o INNER JOIN syscolumns c ON

            o.id = c.id INNER JOIN systypes t ON

            c.xtype = t.xtype

WHERE o.xtype = 'U'

            AND o.name <> 'dtproperties'

            AND t.name <> 'sysname'

ORDER BY o.name ASC, c.colorder

 

This returns a recordset of all the tables and columns in my database. I can see the column length, type, and if it’s nullable. I also have a COLUMN_STATUS column which I don’t really understand, but have worked out that it contains 9 if the column is an identity insert. Ideally what I want is a column called IS_IDENTITY which returns 1 if the column is an identity and 0 otherwise. Can anyone here show me how to tweak the SQL to get that?

 

Many thanks,

 

Douglas

Reply via email to