I am trying to insert data in table, but if it already exists in table, then it should not add.
This is the code, what I came up, but it still adds multiple data with same values.
insert into nol_art_izm([ART_ID],[DAT])
select distinct
v.id_art, {fn now()}
from
openxml(@hDoc, '/art_kompl/nol_voac') with #vc xd
inner join nol_voac v on xd.id_art = v.id_art
where
not exists(select * from nol_art_izm where nol_art_izm.art_id=xd.id_art)
I want that there aren’t any duplicate “ART_ID” values
Try
Update:
Try using
GROUP BYto avoid duplicateid_artvalues:Please not that I have chosen the
MAXfunction for aggregating the{fn now()}values (in case there are more such values perid_art). You might want to use another function.