DataDictionarySelect

  • Comments posted to this topic are about the item DataDictionarySelect

  • The ForeignKeySource displays the table of the foreign key but not use the column name form that table.
       ,ForeignKeySource = ISNULL
            (
                (
                SELECT TOP (1) QUOTENAME(ss.name) + '.' + QUOTENAME(so.name) + '.' + QUOTENAME(c.name)
                FROM sys.foreign_keys AS fk
                JOIN sys.foreign_key_columns AS fkc
                    ON fk.object_id = fkc.constraint_object_id
                JOIN sys.objects AS so
                    ON fkc.referenced_object_id = so.object_id
                JOIN sys.schemas AS ss
                    ON so.schema_id = ss.schema_id
                WHERE
                    fkc.parent_object_id = c.object_id
                    AND fkc.parent_column_id = c.column_id
                )
            ,''
            )

    Alias c is for the column being displayed in the ColumnName column.

  • Thank you for this script, I was just think that it would be really great to get this information out of my ERP database. Vendors think their developers know the tables we should know them too. I have been trying to create and modify reports trying to find the foreign keys, this will help me.

    Thank you,

  • Grasshopper, thank you! Precisely the feedback that's needed. I will post a correction soon.

  • patrick.slesicki - Tuesday, February 27, 2018 7:16 PM

    Grasshopper, thank you! Precisely the feedback that's needed. I will post a correction soon.

    Also, glad you found the script useful. I'd been looking for a quick dd solution for the longest time and decided to write it.
    I just added the foreign key feature recently; again, thank you for the observation!

Viewing 5 posts - 1 through 4 (of 4 total)

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