how to move data from one table to another table

  • i have a table attendance_details in both database DB1 and DB2, i need to move 01/7/14 and 02/7/14 records from db1 to db2,

    My table contains

    employee_no INT,

    date_of_attendance datetime,

    present varchar(20),

    shift_type VARCHAR(20),

    marked_by VARCHAR(50)

    can anyone help me? 🙂

  • INSERT INTO db1.dbo.attendance_details(employee_no,date_of_attendance,present,shift_type,marked_by)

    SELECT employee_no,date_of_attendance,present,shift_type,marked_by

    FROM db2.dbo.attendance_details

    WHERE date_of_attendance IN ('2014-07-01','2014-07-02');

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • thnak u:-):-):-):-)

  • Koen Verbeeck (7/29/2014)


    INSERT INTO db1.dbo.attendance_details(employee_no,date_of_attendance,present,shift_type,marked_by)

    SELECT employee_no,date_of_attendance,present,shift_type,marked_by

    FROM db2.dbo.attendance_details

    WHERE date_of_attendance IN ('2014-07-01','2014-07-02');

    Might need to tweak your filter a bit:

    --

    WHERE date_of_attendance >= '2014-07-01' and date_of_attendance < '2014-07-03'

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Phil Parkin (7/29/2014)


    Koen Verbeeck (7/29/2014)


    INSERT INTO db1.dbo.attendance_details(employee_no,date_of_attendance,present,shift_type,marked_by)

    SELECT employee_no,date_of_attendance,present,shift_type,marked_by

    FROM db2.dbo.attendance_details

    WHERE date_of_attendance IN ('2014-07-01','2014-07-02');

    Might need to tweak your filter a bit:

    --

    WHERE date_of_attendance >= '2014-07-01' and date_of_attendance < '2014-07-03'

    Ah yes, the data type is datetime and not date. Nicely spotted.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply