I am new in sql server.
I have a two tables [FLT_SKDL]
where multiple duplicates numbers are there and [SHIP]
where primary key is used and want to insert only one ID.
And I want to insert data from [FLT_SKDL]
to [SHIP]
in my [SHIP] table there is primary key is used so I should have to ignore duplicates I used following syntax.
INSERT INTO DB01TD02.BRIC.SHIP
SELECT SHIP_NO, SHIP_TYPE_IATA, SHIP_TYPE_DIA, SHIP_TYPE_ICAO, SYSDATETIME(),'EMP', 'BRIC', SYSDATETIME(),'EMP', 'BRIC'
FROM DB01TD02.BRIC.FLT_SKDL
WHERE NOT EXISTS(SELECT SHIP_NO FROM DB01TD02.BRIC.SHIP WHERE DB01TD02.BRIC.SHIP.SHIP_NO = DB01TD02.BRIC.FLT_SKDL.SHIP_NO)
AND DB01TD02.BRIC.FLT_SKDL.SHIP_NO IS NOT NULL
I Tried
But not worked in my case. Is there any another solution. Thanks in advance