The following code inserts a new row into a table based on a value in another row but it also allows duplicate data. I want to use NOT EXISTS so that if there is already a row with that value then it won't insert another one, but not sure how to integrate this.
INSERT INTO [Grading].[dbo].[tblObservations]
([FormID]
,[Data]
,[UserID]
,[DateOfObservation]
,[Final]
,[ValidTo]
,[ID_Grading]
,[ID_ObservationKind]
,[Created]
,[Modified]
,[RowVersion])
SELECT [FormID]
,'0'
,[UserID]
,[DateOfObservation]
,[Final]
,[ValidTo]
,[ID_Grading]
,40
,[Created]
,[Modified]
,[RowVersion]
FROM [Grading].[dbo].[tblObservations]
WHERE [ID_ObservationKind] = 39 AND [Data] = 'No' AND [Final] = 1
Any help appreciated.