Link to home
Start Free TrialLog in
Avatar of davidvilson
davidvilson

asked on

move table1 contents to table2 from different databases

Dear experts,

I got a request in my office today ..

I need to move contents from table1 (from database1) to table2(database2)..

Could any one please tell me the sql/plsql/cursor code that will do this job of moving records from one table to other from different databases..
Avatar of Aneesh
Aneesh
Flag of Canada image

its been answerd with ur previous post

yes, you need to provide the qualified name for that  (databasename.dbo.tableName )

INSERT INTO  database1.dbo.Table2
SELECT * FROM  database2.dbo.Table1
IF @@ROWCOUNT > 0
  TRUNCATE TABLE Table1
Avatar of davidvilson
davidvilson

ASKER

But why this if@rowcount > 0, truncate table table1 ????

Also, since im doing this job every day as schedule, table1 records have to be appended to table2.. It should not simply add or over write in table2..
Records should be appended to the existing table2.  does the above query appends?
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sry, what an idiot Iam