1

I have one Employee table in my Database which has relations to different other tables. In my application, When a user try to delete one employee which has relational data in other tables, I want to display a list of that tables to the user. Can I list all table names which prevents the Employee to be deleted (relational data Tables) using a query?

1
  • 1
    You can do with sys tables (check this stackoverflow.com/questions/8094156/… ), but in realtime that can be performance botteneck. I would suggest to return this list manually or let exception thrown having proper rollback mechanism. Commented May 7, 2015 at 6:40

1 Answer 1

2

Assuming there are foreign keys set up, you should be able to run this stored procedure.

EXEC sp_fkeys 'Employee'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.