Freeform Friday 7

Simply write about the first thing that comes to your mind …. NOW!

I have two new favorite commands in SQL Server, especially given the insane digging I’ve done in a huge database with oddly named columns and tables:

EXEC sp_fkeys '[Table_Name]'

This gem will give you all of the foreign keys for a given table, and what table they are referencing. Helpful when building things out or tracking them down.

Update: Looking for the opposite? Looking for the tables/keys that are referencing the table you’re inspecting, use this syntax

EXEC sp_fkeys @fktable_name='[Table_Name]'

That will flip the data around.

SELECT * FROM information_schema.COLUMNS WHERE column_name like '%[Column_Name]%'

Wondering where in the world the table that said column in a side referenced documentation / form is actually located at, this will find it for you. It also includes views.

Any other handy SQL Server tricks to share? 




What are your 10 bits on the matter? I want to know!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s