Table properties / Nested Select

  • The query below does not return expected results with SOME databases.
    If I run the two queries separately I get the desired results.
    Any idea what is wrong?
    Cheers,
    Julian


    SELECT  TABLE_SCHEMA, TABLE_NAME,
            '[' + TABLE_SCHEMA + '].' + '[' + TABLE_NAME + ']' SchemaAndTable,
            (    
            SELECT  name IDColumn
            FROM    syscolumns
            WHERE   COLUMNPROPERTY(id, name, 'IsIdentity') = 1
                    AND TABLE_NAME = OBJECT_NAME (ID)
            )    
            as IdColumn
    FROM    [WZH].INFORMATION_SCHEMA.TABLES
    WHERE   TABLE_TYPE = 'BASE TABLE'

  • Sorry, found the issue.


    use WZH;
    GO

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply