SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DataDictionarySelect


DataDictionarySelect

Author
Message
patrick.slesicki
patrick.slesicki
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 55
Comments posted to this topic are about the item DataDictionarySelect
aig
aig
Valued Member
Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)

Group: General Forum Members
Points: 66 Visits: 152
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.

aig
aig
Valued Member
Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)

Group: General Forum Members
Points: 66 Visits: 152
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,
patrick.slesicki
patrick.slesicki
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 55
Grasshopper, thank you! Precisely the feedback that's needed. I will post a correction soon.
patrick.slesicki
patrick.slesicki
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 55
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!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search