Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
chiragvm
Yak Posting Veteran
65 Posts |
Posted - 2011-12-08 : 09:10:31
|
| Hi to allI have a two table Tab1 and Tab2 In TAb1 Have 3 Primary Key PK1,Pk2,Pk3Tab2 has reletionship with Tab1, so All 3 primary column generate in Tab2 like FPk1,FPk2,FPk3now i want to get associat primary column with foreign key column. how i can get itmy query is dynamic generate so Select * from Tab2,Tab1Where Tab2.Fpk1 = Tab1.Pk1 Tab2.Fpk2 = Tab1.Pk2Tab2.Fpk3 = Tab1.Pk3I WANT TO FIND OUT BOLD PART |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 09:12:51
|
| why is your query dynamic? i cant see any reason for making it dynamic here------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
chiragvm
Yak Posting Veteran
65 Posts |
Posted - 2011-12-08 : 09:25:17
|
| in my app user select fields base on selected field i have to generate a query and execute it i have a list of column in both table but how to identify Tab2.Fpk1 is a foreign key of Tab1.Pk1 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 09:35:30
|
| you can check sys.foreign_keys catalog view for that------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|