Morning Guys,
I need help with this query below.
-
This table contains 300 million rows.
-
The table have no primary key.
-
PatientID can have multiple TreatmentCodes but different dates.
-
ConsultantID is unique but, sometimes blank.
-
I want to insert the record into a table using batches of 25,000 per row.
-
How do I do this without repeating already inserted row.
-
I have used SSIS package and it works but, how do I handle this in SQL. Thanks in advance.
DECLARE @TestData TABLE
(PatientID varchar(255),
EventDate varchar(10),
TreatmentCode varchar(255),
ConsultantID varchar(255)
)
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099000', '20200401', 'Xc001', '100001');
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099000', '20200402', 'Xc001', '100004');
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099000', '20200403', 'Xc002', 'null');
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099001', '20200401', 'Xc006', '100001');
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099001', '20200402', 'Xc006', 'null');
INSERT INTO @TestData (PatientID, EventDate, TreatmentCode, ConsultantID)
VALUES ('10XX1099001', '20200403', 'Xc002', 'null');
Select * from @TestData