How to get reference information between parent and child tables (MS SQL Server/MSAccess)?
Is it possible to get information about whether a child table has reference to a parent table through a certain record? For example, tblParent has a record whose primary key value is 5. I want to know whether tblChild_A, tblChild_B and tblChild_C have one or more 开发者_运维知识库records in them where the foreign key value is 5. Well it's definitely possible by querying each of the child tables individually but I want to know whether there's any system query or stored procedure or whatever that produces a tabular output from all those tables together. If it's possible in MS SQL Server then please also inform what's its counterpart in MS Access. Regards.
Lots of arguments here. I want to know how this can be done in MSSQL Server as well as MS Access.
I described a possible solution on how to do this in SQL Server here: SQL Server: how to know if any row is referencing the row to delete.
Access/Jet/ACE offers no such system query/sproc for this purpose. You'd have to code it up individually, though if you wanted it to be generalized, you could use the TableDefs and Relationships collections to figure out what tables to look at.
精彩评论