Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

What's wrong

$
0
0

The SP job has been running fine until 2 weeks ago, and the error occurs at 4th line from the bottom in BOLD.

Really appreciate any expert advise on this!

GO
ALTER PROCEDURE [dbo].[UpdateJobs]

AS
BEGIN
SET NOCOUNT ON;


MERGE ConvertedJobs AS target
USING (
SELECT  j.Job_No,  p.Part_No, p.Revision, jt.Job_Type
FROM [ODBCdb].dbo.Job_Op jo
JOIN [ODBCdb].dbo.Job j ON j.Job_Key = jo.Job_Key
JOIN [ODBCdb].dbo.Job_Type jt ON jt.Job_Type_Key = j.Job_Type_Key
JOIN [ODBCdb].dbo.Job_Status js ON js.Job_Status_Key = j.Job_Status_Key
JOIN [ODBCdb].dbo.Job_Op jo2 ON jo2.Job_Key = j.Job_Key
JOIN [ODBCdb].dbo.Part p ON p.Part_Key = j.Part_Key
WHERE jo.Operation_Key = 310 AND jo.Complete_Date is null  AND
jo2.Operation_Key = 182 AND jo2.Complete_Date  is not null AND 
jt.Job_Type = 'Conversion' AND
js.Job_Status NOT IN ('Cancelled','Completed')
) AS source (Job_No, Part_No, Revision, Job_Type)
ON (target.JobNumber = source.Job_No)
WHEN MATCHED AND
(
target.PartNo <> source.Part_No
OR target.PartRevision <> source.Revision
OR target.JobType <> source.Job_Type
)
THEN
UPDATE SET PartNo = source.Part_No, PartRevision = source.Revision, JobType = source.Job_Type
WHEN NOT MATCHED THEN
INSERT(JobNumber, PartNo, PartRevision, JobType)
VALUES (source.Job_No, source.Part_No, source.Revision, source.Job_Type);


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>