How to add linked data?

Discussion of open issues, suggestions and bugs regarding database management and development tools for SQL Server
Post Reply
areachz
Posts: 3
Joined: Mon 05 Oct 2015 21:52

How to add linked data?

Post by areachz » Mon 05 Oct 2015 22:15

I have two tables that are linked by a foreign key.

Table_A
Id, PK, AUTO_INCREMENT
Date, IX
Table_B
A_Id, PK, Foreign Key Table_A, Id
Id, PK
Value

I want to append to the destination two sets of the data from the source. Suppose

In source:
Table_A
{ 30, '2015-09-01' }
Table_B
{ 30, 1, "<src>" }
In Destination
Table_A
{ 30, '2015-08-31' }
Table_B
{ 30, 3, "<some stuff>" }

Comparing the index on Date, source has data that the destination does not have even though the primary keys are the same. What I'd like the software to do automatically is
INSERT INTO Table_A (Date) VALUES ('2015-09-01')
// get the new primary key, name it @pkA
INSERT INTO Table_B VALUES (@pkA, 1, "<src>")

How can I do this?

alexa

Re: How to add linked data?

Post by alexa » Tue 06 Oct 2015 15:44

You can perform the following:

1. On the 'Source and Target' page of the data comparison wizard, select the compared databases and click 'Next'.
2. On the 'Options' page select the 'Only in target records' option and click 'Next'.
3. On the 'Mapping' page, click the three-dotted button against the row 'Table_A:'. The 'Column Mapping' dialog box opens.
4. Unselect the 'ID' field.
5. Select the checkbox against 'date' in the 'Key' column.
6. Click 'OK'.
7. Click 'Compare'.

When a *.dcomp data comparison document is generated, right-click in the grid and select 'Synchronize...' from the popup menu. This will generate a synchronization script.

areachz
Posts: 3
Joined: Mon 05 Oct 2015 21:52

Re: How to add linked data?

Post by areachz » Wed 14 Oct 2015 16:28

Thanks. I don't have a problem comparing Table_A. The problem is the referencial constraint in B is not being taken care of.

Please reread the original question. I tried the instruction you provided before I came to the forum, and it doesn't work.

alexa

Re: How to add linked data?

Post by alexa » Thu 15 Oct 2015 16:55

We are currently investigating this issue and will answer you as soon as possible.

alexa

Re: How to add linked data?

Post by alexa » Wed 28 Oct 2015 09:39

Unfortunately, dbForge can't perform this because dbForge adds a value into the Table_A as AUTO_INCREMENT. Therefore, the value of type AUTO_INCREMENT can't be added into the Table_B due to being not known by the moment of generating the corresponding INSERT statement.

Post Reply