S
S
Samir Kurbanov2020-11-03 17:39:18
SQL Server
Samir Kurbanov, 2020-11-03 17:39:18

Is it possible to insert a record into related tables with a strict 1 to 1 relationship?

There are two tables. Both tables have a unique field [pid] (primary key). Created a link between the first table and the second one by the [pid] field and vice versa .
The question is how to insert records into such tables? Tried transaction, no success.

I know, instead of such a relationship, you can simply combine everything into one table. But there are a lot of fields in each of them, and when writing queries, more often fields are needed only from the first table.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mart kurtz, 2020-11-12
@Tougric

Hello!
If I understood the question correctly, then, in fact, the problem is in writing to a linear table.
You are probably using INSERT incorrectly or something like that. For example, with syntax errors.
I suggest you drop the transaction for the time being and just pump the use of INSERT on copies of your tables. first correctly write the data to the first table, then to the second. When everything works out, already use the transaction.
I don't think the problem is deep. Chances are you just don't have a lot of experience.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question