views:

32

answers:

1

I am trying to figure out where my primary keys of a table with translation per language resides as a foreign key.

This is what i already have ...

SELECT *
FROM (  SELECT TM.seqtrans, T.trans,  CASE T.seqlang WHEN 1 THEN 'NL'
                                                     WHEN 2 THEN 'FR'
                                                     WHEN 3 THEN 'EN'
                                                     WHEN 4 THEN 'DE'
                                                     WHEN 12 THEN 'SK'
                                                END lang
        FROM acc.translation_map TM
                INNER JOIN acc.translation T on TM.seqtrans = T.seqtrans 
        WHERE TM.seqcust = @seqcust  ) AS p
PIVOT ( MAX(trans) FOR lang IN ([NL],[FR],[EN],[DE], [SK]) 
       ) AS pvt

Now i need to somehow use a system table to check the seqtrans and show all the tablenames.

Is this possible?

A: 

The system stored procedure sp_fkeys is what you need, and you can call it like this:

EXECUTE sp_fkeys @pktable_name = 'translation'

Books Online has more info about the other parameters and what they do.

vincebowdren