Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SP with multiple tables and databases (insert & delete)
Message
 
 
À
26/02/2003 12:32:01
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00758108
Message ID:
00779577
Vues:
10
>Two comments:
>
>1) instead of
>
>>UPDATE cart
>>SET LastModified = CURRENT_TIMESTAMP
>>,@CartID = cartid
>>FROM cart
>>WHERE userid = @tnUserID
>>
>>IF @@RowCount = 0
>>BEGIN
>> INSERT INTO cart blah blah blah
>> @cartid = @@SCOPE_IDENTITY
>>END
>
>you'd be better off with
>
>IF EXISTS (SELECT * FROM cart WHERE cartid = @cartID)
> >UPDATE cart
> >SET LastModified = CURRENT_TIMESTAMP
> >,@CartID = cartid
> >FROM cart
> >WHERE userid = @tnUserID
>ELSE
> >INSERT INTO cart blah blah blah
> >@cartid = @@SCOPE_IDENTITY
>
>It'll be much better on your locks and concurrency

Hi Mike,

Sorry for the old thread. I was just re-reading it and I have a question:

would it be better to change
IF EXISTS (SELECT * FROM cart WHERE cartid = @cartID)
to
IF EXISTS (SELECT CartID FROM cart WHERE cartid = @cartID)
Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform