Avatar of 2575069
2575069

asked on 

How to setup multiple relationships between 2 tables

Hi,

I have two tables; let's say Table 1" and "Table 2".

Table 1                        Table 2
------------               --------------
Field 1                         Field 1
Field 2                         Field 2
Field 3                         Field 3
Field 4                         Field 8
Field 5                         Field 9
Field 6                         Field 10

I want to establish a relationship between these 2 tables by pulling the fields (field 1, field 2, and field 3) from Table 1 into Table 2.
I tried to create 3 Primary keys on table 1 and when I tried to create  those fields as a foreign keys in Table 2 I am getting the below error message

The columns in table table1 do match an existing primary key or unique key constraint.

Thanks,
Vamshi
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
2575069
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of 2575069
2575069

ASKER

I want to pull some fields from Table 1 i.e Field1, Field 2, Field 3 into Table 2 ( these fields should be same in both tables)
Avatar of chapmandew
chapmandew
Flag of United States of America image

youre talking for creating the relationship, right?
Avatar of 2575069
2575069

ASKER

Yes, i want create the relationship between those 2 tables.
Avatar of chapmandew
chapmandew
Flag of United States of America image

Good deal...I just told you how to do it.

If you're referring to actually getting the data from one table to the other, it will need to be maintained through code....but creating the actual FK constraint is a one time thing.
SOLUTION
Avatar of dportas
dportas

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of 2575069
2575069

ASKER

Thanks alot..its working now.

Regards,
Vamshi
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo