Question : Multiple relations between tables, modifying one.

See question
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_24494762.html

I have been given the following SQL Query:
select fko.name as [FK Name], fk.constraint_column_id as [Col Order],  
fks.name + '.' + fkt.name as [FK table], pc.name as [FK column], rcs.name + '.' + rct.name as [PK table], rc.name as [PK column]
  from sys.foreign_key_columns fk
    -- FK columns
    join sys.columns pc  
      on fk.parent_object_id = pc.object_id
        and fk.parent_column_id = pc.column_id
    join sys.objects fkt
      on pc.object_id = fkt.object_id
    join sys.schemas as fks
      on fks.schema_id = fkt.schema_id
   -- referenced PK columns
    join sys.columns rc  
      on fk.referenced_object_id = rc.object_id
        and fk.referenced_column_id = rc.column_id
    join sys.objects rct
      on rc.object_id = rct.object_id
    join sys.schemas as rcs
      on rcs.schema_id = rct.schema_id
    -- foreign key constraint name
    join sys.objects fko  
      on fk.constraint_object_id = fko.object_id
        --and fk.referenced_column_id = rc.column_id
  order by fko.name, fk.constraint_column_id

Say I have a relation between two tables using two fields in each table.  The relation name appears twice (eg. Accnt_FK00) with the field [Col Order] having values of 0 and 1. OK that part I see, but if I want to modify the relation (eg. remove the linkage so it is on only one field - we are talking rather theoretical here) do I have to drop the foreign key completely and recreate it or can I pick out one part and modify that?

Answer : Multiple relations between tables, modifying one.

Even if you have multiple columns involved it would be treated as a single relationship only..

<< so I have to work on the relation as a whole. >>
Yes.. you have to
Random Solutions  
 
programming4us programming4us