Information générale
Forum:
Microsoft SQL Server
>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement