I'm trying to move specific data from three linked tables on a source database to three tables on a destination database by generating dynamic SQL INSERT scripts but am getting stuck on the last set of INSERT statements. I don't think I can use SSIS because the source autonumber fields may already exist on the destination side but I could be wrong.For simplicity, Table 1 (T1) has one autonumber key of PK1 as well as other fields (A1, B1, etc.).Table 2 (T2) has one autonumber key of PK2 and a foreign key (FK1) that links back to PK1 as well as other fields (A2, B2, etc.).Table 3 (T3) has one autonumber key of PK3 and a foreign key (FK2) that links back to PK2 as well as other fields (A3, B3, etc.).Like this:[b]T1:[/b] PK1, A1, B1, etc.[b]T2:[/b] PK2, FK1, A2, B2, etc.[b]T3:[/b] PK3, FK2, A3, B3, etc.So, I'm able to query the source database T1 to generate my dynamic SQL INSERT statements that will be run on the destination side. I'm also able to generate my dynamic SQL statements to insert into T2 but when I get to T3 I currently am stuck figuring out how to insert because the destination side is unable to match it's FK2 to the just inserted PK2. It throws the below error. [i]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.[/i]Is what I'm trying to do not possible? Is there another way to accomplish this?Thanks,Greg:unsure:
↧