Aren’t correlation IDs ok in MSSQL for an UPDATE statement?

55 pts.
Tags:
SQL error messages
SQL tables
I'm getting the following error with the attached SQL statment on MSSQL:

UPDATE IMMUNE I

Software/Hardware used:
MSSQL

Answer Wiki

Thanks. We'll let you know when a new response is added.

Why do you need the alias when you are referencing only one tabe ?

You can use aliases in updates, but I think it should be something like ths:

<pre>UPDATE IMMUNE
SET FLDENCOUNTR =
(SELECT MIN(E.FLDREC_NUM)
FROM ELOG E INNER JOIN EMPLOYEE M
ON E.FLDEMPLOYEE = M.FLDREC_NUM
WHERE E.FLDDATE = I.FLDDATE
AND M.FLDREC_NUM = I.FLDEMPLOYEE)
<b>FROM INMUNE I</b>
WHERE I.FLDENCOUNTR IS NULL
AND EXISTS
(SELECT *
FROM ELOG E INNER JOIN EMPLOYEE M
ON E.FLDEMPLOYEE = M.FLDREC_NUM
WHERE E.FLDDATE = I.FLDDATE
AND M.FLDREC_NUM = I.FLDEMPLOYEE)</pre>

Also, I’d change this:

<pre>…AND EXISTS
(SELECT * …</pre>

for this:

<pre>…AND EXISTS
(SELECT <b>1…</b> </pre>

—————————–

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • DeloeranGuy
    I'll try that - thanks! Just FYI, our site uses aliases as a standard. Even though there's one table, the data for the update comes from another table that has the same field names ("Date"). Thanks!
    55 pointsBadges:
    report
  • carlosdl
    It seems that the original question was truncated. DeloeranGuy, can you post your original question again (here in the discussion section) for future reference, when you have time ? Thanks.
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following