Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Puzzler
Message
From
05/02/2005 04:09:16
 
 
To
04/02/2005 15:52:42
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
00983656
Message ID:
00984147
Views:
30
>Hi Fabio,
>
>Thanks for replying.
>
>>Info are insufficient ( PKEY(EnrollmentSchool2) IS ? Assume: ISMId):
>
>The PK for EnrollmentSchool2 is ENRid.
>
Ok.

But , EnrollmentSchool2.ENRid is not used in Update,
and then, without a surrogate primary key, ( EnrollmentSchool2.ISMId is not unique ),
you cannot do this with a single update ( of course, without triggers ).

This, because with the check HAVING NOT IN exclude the MIN(enr.EnrId)
that exists in EnrollmentSchool2 before the UPDATE run,
but the SET can assign the same MIN(enr.EnrId) to 2 EnrollmentSchool2
different rows ( 2 different EnrollmentSchool2.ENRid ).

Then, you have to found a row by row correlate expression
between the updated EnrollmentSchool2 table and the SELECT min() subquery.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform