Yogi Thanks for your response. I hope you didn't understand my question. let me explain with example
Consider TableA had primary key Named RowId. This primary key referenced as foreign key in TableB and TableC. So my question is there any query to list TableB and TableC which is refrenced to tableA as foreign Key?
Consider TableA had primary key Named RowId. This primary key referenced as foreign key in TableB and TableC. So my question is there any query to list TableB and TableC which is refrenced to tableA as foreign Key?
From your description, it seems that you want to query the related entities.
If you are using SQL command to query the related table, you could use a
SQL join clause to join the tables and get the value.
If you are using Entity Framework, you could load related entities using the Include method, more details about loading related entities, please check the following articles:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
30 Points
132 Posts
List all table referenced by foreign key from table
Jan 02, 2019 11:48 AM|binustrat|LINK
Star
10303 Points
2359 Posts
Re: List all table referenced by foreign key from table
Jan 02, 2019 11:54 AM|yrb.yogi|LINK
Use
You will get details here
Sr Technical Lead
Ahmedabad, India
Member
30 Points
132 Posts
Re: List all table referenced by foreign key from table
Jan 02, 2019 12:09 PM|binustrat|LINK
Yogi Thanks for your response. I hope you didn't understand my question. let me explain with example
Consider TableA had primary key Named RowId. This primary key referenced as foreign key in TableB and TableC. So my question is there any query to list TableB and TableC which is refrenced to tableA as foreign Key?
All-Star
45489 Points
7008 Posts
Microsoft
Re: List all table referenced by foreign key from table
Jan 03, 2019 01:46 AM|Zhi Lv - MSFT|LINK
Hi binustrat,
From your description, it seems that you want to query the related entities.
If you are using SQL command to query the related table, you could use a SQL join clause to join the tables and get the value.
If you are using Entity Framework, you could load related entities using the Include method, more details about loading related entities, please check the following articles:
EF core Loading Related Entities
EF 6 Loading Related Entities
Loading Related Entities in EF 6 and EF Core
Best regards,
Dillion
Star
10303 Points
2359 Posts
Re: List all table referenced by foreign key from table
Jan 03, 2019 07:23 AM|yrb.yogi|LINK
You must need to visit this links.
https://www.mssqltips.com/sqlservertip/4753/list-dependencies-for-sql-server-foreign-keys/
https://www.mytecbits.com/microsoft/sql-server/list-all-foreign-keys-referencing-a-table
Sr Technical Lead
Ahmedabad, India