|
Posted by Robert Klemme on 01/19/07 09:36
Please don't top post.
On 18.01.2007 21:47, Plamen Ratchev wrote:
> I agree on the performance note and use of SCOPE_IDENTITY(), I was just
> trying to simplify things and illustrate better the steps.
With all due respect, don't you think my solution is simpler or at least
as simple? There's not really a difference in complexity between
SCOPE_IDENTITY() and @@IDENTITY and your solution needs one more SQL
statement. :-)
> But if there is
> concurrent activity this better be in a transaction, as even in your example
> if siteID is NULL by the time you insert it there might be another insert
> with the same siteName and the statement will result in error.
Of course all this must be in a transaction - how would you execute the
code without TX at all, especially since it's in a stored procedure?
> And not an
> issue with uniqueness for siteName as it was indicated there is unique
> constraint on it.
Ah, thanks! I hadn't seen that.
Regards
robert
Navigation:
[Reply to this message]
|