Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Puzzler
Message
 
 
To
03/02/2005 16:57:07
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
00983656
Message ID:
00983681
Views:
30
Hi Gary,

Can you explain what your UPDATE is doing/suppouse to do?

>
>I am using the following code :-
>
>
>UPDATE EnrollmentSchool2
>SET		PKOutRec = (
>SELECT 	        MIN(enr.EnrId)
>FROM		Enrollment enr
>WHERE  	        enr.ISMid = EnrollmentSchool2.ISMId
>AND 		enr.[Date] > EnrollmentSchool2.StartDate
>AND 		enr.Active = 0)
>
>
>What I would like to do (if possible) is, in the same update statement, check whether the value MIN(enr.EnrId) being assigned to PKOutRec has already been assigned to PKOutRec earlier in the update statement and make it a condition in the WHERE clause in the SELECT statement ie.,
>
>
>AND NOT MIN(enr.EnrId) IN SELECT PkOutRec FROM EnrollmentSchool2
>
>
>I realise I am expressing this incorrectly (SQL server tells me so <s>). However, I want to enforce this check so that PKOutRec is unique which will in turn ensure my logic for this UPDATE works correctly.
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform