We have a web app that lets users create records in a table, then assign those to other records using primary keys and foreign keys. If a user tries to delete one of the master records while it's linked using a FK, it will error. I have it catching this error now, but I'd like to deny deleting the record if it's linked. I want them to still be able to delete records not in use. Is there a simple way to return this in the query?
Table1
id int identity PK
field1 varchar
field2 varchar
Table 2
id int identity PK
Table1_id int FK
field1 varchar
field2 varchar
Select id,field1,field2,??inuse?? from Table1
So when I return the results from this query to the page, I can disable the delete function if inuse = 1.
There are 10 types of people in the world, those that understand binary, and those that don't.
Table1
id int identity PK
field1 varchar
field2 varchar
Table 2
id int identity PK
Table1_id int FK
field1 varchar
field2 varchar
Select id,field1,field2,??inuse?? from Table1
So when I return the results from this query to the page, I can disable the delete function if inuse = 1.
There are 10 types of people in the world, those that understand binary, and those that don't.