273 words
1 min
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?

art-graffiti-abstract-vintage.jpg

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?

art-graffiti-abstract-vintage.jpg

Freeform Friday 7
https://dillieo.me/posts/development/2016-05-06-freeform-friday-7/
Author
Sean Patterson
Published on
2016-05-06
License
CC BY-NC-SA 4.0