I've been asked to convert this statement from PL/SQL to SQL Server:
UPDATE pdi_nb_process_complete pdi_end1
SET (pdi_end1.adp_issue_date_time, pdi_end1.adp_print_date_time) =
(SELECT DISTINCT pdi_end1.completion_date + 2
,pdi_end1.completion_date
FROM cl100 cl
WHERE cl.polref = pdi_end1.policy_reference
AND cl.doctyp = 'PSP')
WHERE pdi_end1.adp_print_date_time IS NULL
A straight copy/paste doesn't work - you get a compile error. The closest I have managed is this:
UPDATE pdi_end1
SET pdi_end1.adp_issue_date_time = pdi_end1.completion_date + 2,
pdi_end1.adp_print_date_time = pdi_end1.completion_date
from pdi_nb_process pdi_end1
INNER JOIN cl100 cl ON cl.polref = pdi_end1.policy_reference
AND cl.doctyp = 'PSP'
WHERE pdi_end1.adp_print_date_time IS NULL
But this leaves me short of the DISTINCT. Does anyone have any suggestions?
You can assume the Oracle and SQL Server Databases have the same tables and fields.
Thanks