>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