SQLTeam.com | Weblogs | Forums

Copying data between two databases using Transact SQL on same Server


How do I copy data from 10 columns in Table A, Database A to Table B, Database B on the same server.
I need to mark the data I copied, then repeat the process every 30 mins.
I plan on using the SQL Agent for creating a job to run the SQL for the process.

Any Advice ?




here it is using a [mark] column to indicate that the record has been copied over to TableB.

UPDATE    [DBa].[dbo].[TableA]
SET       mark = 1
OUTPUT    inserted.col1, inserted.col2, inserted.col3  
INTO      [DBb].[dbo].[TableB] (col1, col2, col3)
WHERE     mark = 0