I have lookup table, whose records are being referenced in other tables. For example, a countries lookup table, and a user table referc the country id from countries table.
I want to know, how i can get count of references and all the rows in other tables, which have a record with a country id.
If a reference of a row is found anywhere else, i need to show an alert to user that this record is being referened, and cannot be deleted, and list down all the referenced rows in a grid.
I have seen a similar topic at
SQL Server: how to know if any row is referencing the row to delete
But the answer didn't helped at all, and gave an error.