Daily Shaarli
All links of one day in a single page.
Locating the row to confirm it exists, only to have to locate it again in order to update it, is doing twice the work for nothing.
BEGIN TRANSACTION;
UPDATE dbo.t WITH (UPDLOCK, SERIALIZABLE) SET val = @val WHERE [key] = @key;
IF @@ROWCOUNT = 0
BEGIN
INSERT dbo.t([key], val) VALUES(@key, @val);
END
COMMIT TRANSACTION;