Re: asynchronous select statements

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mike Epprecht \(SQL MVP\) (mike_at_epprecht.net)
Date: 02/15/05


Date: Wed, 16 Feb 2005 00:07:26 +0100

Have the app call a single SP.

This SP updates the record, and then returns it to the client application.
This is in one transaction, so the other application can not get to the same
record.

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Jeremy Chapman" <NoSpam@Please.com> wrote in message
news:#GXM3G7EFHA.1084@tk2msftngp13.phx.gbl...
> We have an application deployed on two seperate machines both reading from
> the same database. The applications poll the database every few seconds
and
> find the first record in a table that has a bit field set to 0x0. The
> application then updates the field to a value of 0x1 and then do some
> processing based on the contents of the record. The problem we have is
that
> it is currently possible for each application to get the same record
because
> application 2 might select the record just before application 2 updates
the
> bit flag. we currently use two sql calls (in stored procs) such as:
>
> select top 1 * from table1 where processed = 0x0
>
> update table1 set processed = 0x1 where recid = @ID
>
>
> How can we avoid both apps getting the same record
>
>



Relevant Pages

  • Re: Updating a database
    ... whilst the backend is an Access database. ... >>>I do changes to the app and the database (add fields, change queries, ... >>>User A updates to Version 1.1 ... >> the update by running the appropriate scripts. ...
    (microsoft.public.vb.general.discussion)
  • Re: Like I said...
    ... > rich apps running a unidirectional database connection. ... > Can you access regular $50 USB scanners via TWAIN in an app shared ... > updates to the clients. ... you can only do this with middleware ...
    (borland.public.delphi.non-technical)
  • Re: sql server express connection
    ... is that though the data has been refreshed and the win app ... reconnects to the database to collect the updates it does not ... better way of 2 apps using the same database without having to attach it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Local database and updates
    ... In adding logic to automatically update components of the ... application (content files, assemblies updates, and data updates) I found ... that the original design locks the database while the app is running. ...
    (microsoft.public.sqlserver.msde)
  • asynchronous select statements
    ... the same database. ... find the first record in a table that has a bit field set to 0x0. ... application 2 might select the record just before application 2 updates the ...
    (microsoft.public.sqlserver.programming)