Lets say we have a Table A with primary key column ID. Now this table is in a foreign key relationship with say n other tables on this column.
I need to create a stored procedure which will take an ID as parameter and return 1 or 0 depending upon the value of ID present in any other table.
So for ex if ID =3 and any of the n tables contains 3 the SP should return 1 else 0.
What is the best way to achieve this?
One way is to run n different select queries and process every result. But looks quite clumsy.
Thanks.