January 15, 2009 at 6:04 am
Hi Everyone,
Scenario:I have to populate the records from two different sources into one table.
Now- One column is added in both sources.
I need to bring that column records as well from those two sources into one table.
so how to update the column which is coming from 2 sources??
January 21, 2009 at 8:02 am
How is the data coming? IS it in SQL Server?
January 21, 2009 at 8:39 pm
Yes..data is coming from sql server databases only..
January 21, 2009 at 9:05 pm
i'd simply insert from a UNION of the two alternate sources;
insert into Table1(alotofcolumns)
select alotofcolumns from Server1.Database.dbo.Source1Table WHERE criteria=1
union
select alotofcolumns from Server2.Database.dbo.Source2Table WHERE criteria=1
Lowell
January 21, 2009 at 9:20 pm
Thanks for the reply..
But the thing is...something different..
let me put it on..
I am having the table named TABLE-A in Server1 and TABLE-B in Server2.
I already pulled the records from these two tables into another server Server3's TABLE-C by doing as you mentioned(By Union ALL).
Now, In both sources i.e TABLE-A and in TABLE-B, one new column get added. So I altered the TABLE-C by adding one more column.
Now How can I update this column with the values coming from those two tables i.e TABLE-A and TABLE-B into TABLE-C.
January 21, 2009 at 9:36 pm
it's just an update instead of an insert....but there has to be something to join the data...an ID column or some other criteria.
you should really ALWAYS post the real table definition, along with some sample data....
theoretical "TABLE A AND TABLE B gets you incomplete or non specific answers.
UPDATE TABLE-C
SET TABLE-C.NEWCOLUMN = SUBALIAS.NEWCOLUMN
FROM (SELECT TABLE-A.lotsofcolumns from TABLE-A
UNION
SELECT TABLE-B.lotsofcolumns from TABLE-B
) SUBALIAS
WHERE TABLE-C.ID = SUBALIAS.ID
md.noorullah (1/21/2009)
Thanks for the reply..But the thing is...something different..
let me put it on..
I am having the table named TABLE-A in Server1 and TABLE-B in Server2.
I already pulled the records from these two tables into another server Server3's TABLE-C by doing as you mentioned(By Union ALL).
Now, In both sources i.e TABLE-A and in TABLE-B, one new column get added. So I altered the TABLE-C by adding one more column.
Now How can I update this column with the values coming from those two tables i.e TABLE-A and TABLE-B into TABLE-C.
Lowell
January 21, 2009 at 9:47 pm
sorry and thanks again..
Yeah I have to join on one ID Column and at the same time I need to make sure that there will not be duplicates in the target table as the two source tables contain same ID in their respective tablles
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply