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.
  • 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.
    83,285 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.

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

Following

Share this item with your network: