Re: How to handle concurrency issue with better performance?



Timestamps are great. Cast them as integers and use them in the where
clause.

------------
StatusLookup
------------

SELECT StatusLookupID, Status, Office, EndUser, Consultant,
ConsultantOffice, LastUpdated, LastUpdatedBy, CAST(TS AS INT) AS TS FROM
AgencyNET.StatusLookup

INSERT INTO [AgencyNET].[StatusLookup] ([Status], [Office], [EndUser],
[Consultant], [ConsultantOffice], [LastUpdatedBy]) VALUES (@Status, @Office,
@EndUser, @Consultant, @ConsultantOffice, @LastUpdatedBy);SELECT
StatusLookupID, CAST(TS AS INT) AS TS FROM AgencyNET.StatusLookup WHERE
(StatusLookupID = SCOPE_IDENTITY())

UPDATE [AgencyNET].[StatusLookup] SET [Status] = @Status, [Office] =
@Office, [EndUser] = @EndUser, [Consultant] = @Consultant,
[ConsultantOffice] = @ConsultantOffice, [LastUpdated] = getutcdate(),
[LastUpdatedBy] = @LastUpdatedBy WHERE (([StatusLookupID] =
@Original_StatusLookupID) AND (CAST(TS AS INT) = @Original_TS));SELECT
CAST(TS AS INT) AS TS FROM AgencyNET.StatusLookup WHERE (StatusLookupID =
@StatusLookupID)

DELETE FROM [AgencyNET].[StatusLookup] WHERE (([StatusLookupID] =
@Original_StatusLookupID) AND (CAST(TS AS INT) = @Original_TS))


.