Home Forums SQL Server 7,2000 Strategies Copying Tables structure from SQL 2000 to Local database. RE: Copying Tables structure from SQL 2000 to Local database.

  • You can find that in the sysforeignkeys system table. Here's a query that will list foreign key info for the tables in a database:

    select t.name as 'Table', c.name as 'Foreign_Key_Constraint', rt.name as 'Referenced_Table'

    from (select distinct constid, fkeyid, rkeyid from sysforeignkeys) as FK

    join sysobjects c on c.id = FK.constid

    join sysobjects t on t.id = FK.fkeyid

    join sysobjects rt on rt.id = FK.rkeyid

    order by 1,2,3

    Greg