al4629740
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.tblAttendanc e where tblAttendance.Redeterminat ion = 1 to dbo.database2.tblAttendanc e
How can I do that using SQL statments. Unless there is also a wizard that does this function...
I would like to transfer all records from dbo.database1.tblAttendanc
How can I do that using SQL statments. Unless there is also a wizard that does this function...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My bad! sjwales is spot-on , sorry for the confusion.
EDIT: Oops, replied to wrong Question :)
INSERT INTO database2.dbo.tblAttendanc e(field1, field2, field3,Redetermination)
SELECT field1, field2, field3 , 1 as Redetermination
FROM database1.dbo.tblAttendanc e
SELECT field1, field2, field3 , 1 as Redetermination
FROM database1.dbo.tblAttendanc
SELECT *
INTO dbo.database2.tblAttendanc
FROM dbo.database1.tblAttendanc
WHERE dbo.database1.tblAttendanc