Hi,
I have created the following SQL query. This is fine on initialising the table but for succesive INSERTS, I need to only add records where the combined PostCode fields do NOT already exist in the
dbo.MER_Consignee_PostCodes table.
(PostCode_1 and PostCode_2 are the Primary Key)
Code:
INSERT INTO dbo.MER_Consignee_PostCodes
(
PostCode_1,
PostCode_2,
Previously_Checked,
Active_Last_3_Years
)
SELECT DISTINCT PostCode_1,
PostCode_2,
'1',
'1'
FROM dbo.MER_Consignee_Master
GROUP BY
PostCode_1,
PostCode_2
ORDER BY
PostCode_1,
PostCode_2
Succesive entries must have the
Previously_Checked field set to '0'.
How do I do this within a query?
Thanks in advance,
Neal
A Northern Soul