August 20, 2010 at 2:28 pm
Riddle me this Batman:
Given the following statement:
UPDATE dbo.custf0tax_events_tbl_bob
SET blperobjid = (SELECT top 1 CBP.BlPerObjId
from smsdss.custf0tax_chgblperrptv cbp
WHERE CBP.ChgObjId = evt.ChgObjId AND CBP.chgblperCreDTime < @fiscdatefrom
ORDER BY cbp.chgblperCreDTime DESC)
,
bpbpobjid = (SELECT top 1 bpbp.blperblptyobjid
from smsdss.custf0tax_blperblptyrptv BPBP
WHERE BPBP.BlPerObjId = evt.BlPerObjId
AND bpbp.blperblptycredtime < @fiscdatefrom
ORDER BY BPBP.PrioNo, bpbp.blperblptycredtime DESC)
FROM dbo.custf0tax_events_tbl_bob evt
WHERE event = @scenario
When I run this the first time, the column bpbpobjid is set to null.
When I run it a second time, it sets the value properly.
Why doesn't it set both values the first time?
"Beliefs" get in the way of learning.
August 20, 2010 at 2:37 pm
Forget it. I knew as soon as I asked on this forum I'd see the answer.
The second column is using the value set for the first column in it's subquery.
"Beliefs" get in the way of learning.
August 20, 2010 at 3:18 pm
Robert Frasca (8/20/2010)
Forget it. I knew as soon as I asked on this forum I'd see the answer.The second column is using the value set for the first column in it's subquery.
I guess that happened to the majority of the community at least once... Some of us figured the solution just before posting, some right after posting the question and some as soon as the first questions for clarification came up.
It's great you provided the answer even if you figured it out by yourself. Good job!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply