Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

copy records from one identical table to another identical table on two different datbases

I have database1 with tblAttendance.   I also have database2 with tblAttendance.  There is a column in the table called Redetermination which determines which records will be migrated to the new database and table.

I would like to transfer all records from dbo.database1.tblAttendance where tblAttendance.Redetermination = 1   to dbo.database2.tblAttendance

How can I do that using SQL statments.  Unless there is also a wizard that does this function...
Avatar of duttcom
duttcom
Flag of Australia image

Try this -

SELECT *
INTO dbo.database2.tblAttendance
FROM dbo.database1.tblAttendance
WHERE dbo.database1.tblAttendance.Redetermination = '1'
ASKER CERTIFIED SOLUTION
Avatar of Steve Wales
Steve Wales
Flag of United States of America 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
My bad! sjwales is spot-on , sorry for the confusion.
EDIT: Oops, replied to wrong Question :)
INSERT INTO database2.dbo.tblAttendance(field1, field2, field3,Redetermination)
     SELECT field1, field2, field3 , 1 as Redetermination
     FROM database1.dbo.tblAttendance