Home Forums SQL Server 2008 SQL Server 2008 - General How to get schemaname, tablename, identity column, foreign key constraints RE: How to get schemaname, tablename, identity column, foreign key constraints

  • I tried to get the above qry. could you please check and verify this query...

    select s.name schemaname, o.name tablename, i.name identitycolname,

    ins.constraint_name constraintname

    from sys.schemas s

    join sys.sysobjects o on o.uid = s.schema_id

    left join sys.identity_columns i on o.id = i.object_id

    left join information_schema.constraint_table_usage ins on

    ins.tabnle_name = o.name

    and ins.constraint_name in ( select insc.constraint_name from

    information_schema.referential_constraints insc )

    where o.xtype = 'U'

    order by s.name, o.name

    Thanks in advance..

    Nithiyanandam.S