0

Is there any option to use not exists in openquery from SQL Server and prevent insert of values which already exist in DB2, from table.

I want to insert data from a table located in SQL Server into a table located in an IBM DB2 server, but I want to check if the value already exists or not.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Puskarkc007
  • 174
  • 2
  • 14

1 Answers1

0

This works for me actually,

if not exists (select * from openquery(puskarkc, 'select * from puskarlib.castatus'))
begin
insert openquery (puskarkc, 'select * from puskarlib.castatus') 
select * from castatus
end
Puskarkc007
  • 174
  • 2
  • 14