Good morning all.
I'm sure this is pretty simple, but i'm failing at the moment.
I want to run an insert sql script to insert
new data into a table.
Here is a copy of my script so far.
Code:
insert into TargetTbl (Prefix,Bet1,Updated,Key1,Key2,Key3,Bet2)
select Prefix,Key3,GETDATE(),Key1,Key2,Key3,Key3
from SourceTbl
where ...
This is where i get stuck... I only want records to be imported where the Prefix in SourceTbl is "A", and the fields "Key1" and "Key2" are not collectively already in TargetTbl.
I should probably explain that i already have an UPDATE statement to cater for records where "Key1" and "Key2" are collectively in TargetTbl. I wanted to use a MERGE statement, but due to the unchangeable compatibility level of our database, its not going to happen.
If someone could help or point me in the right direction, i'd greatly appreciate it!
Thank you all.