Tuesday, September 2, 2014

SQL Server: Get Foreign Key Name by Table and Column

I ran across a scenario where I was trying to drop a column that was a foreign key.  When I executed the code to drop it it said there was a dependent object on the column being dropped.  The dependent object was the FK constraint.  So, I need a programatic way of getting the FK constraint name so it could run in our migrations.



The script came from this SO thread.

No comments:

Post a Comment