July 29, 2014 at 1:31 am
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? 🙂
July 29, 2014 at 1:36 am
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
July 29, 2014 at 1:50 am
thnak u:-):-):-):-)
July 29, 2014 at 1:52 am
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'
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
July 29, 2014 at 1:53 am
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