Thanks Stefan,
I am trying the same syntax as you did but still records get
duplicated...here is my query where testTbl is source table & New testTbl is
Destination table.
INSERT INTO [New testTbl] ( ID, ID1, [First], [Last], Age, DOB, Employed,
Experience )
SELECT testTbl.ID, testTbl.ID1, testTbl.First, testTbl.Last, testTbl.Age,
testTbl.DOB, testTbl.Employed, testTbl.Experience
FROM testTbl
WHERE NOT Exists (SELECT * FROM [New testTbl] WHERE [testTbl].[ID] = [NEW
testTbl].[ID] AND [testTbl].[ID1] = [NEW testTbl].[ID1]);
--
Amod Goyal
IT System Developer
NSK Precision America
Stefan Hoffmann said:
hi Amod,
You need a candidate key to identify those records. In the worst case
you have to compare each field (without identity), e.g.:
INSERT INTO destinationTable (field1, ..., fieldN)
SELECT field1, ..., fieldN
FROM sourceTable s
WHERE NOT EXISTS(
SELECT *
FROM destinationTable d
WHERE s.field1 = d.field1 ...
AND s.fieldN = d.fieldN
)
mfG
--> stefan <--