First thing ROWLOCK is not necessary when ever an Update
statement is used this is automatically taken care by the
sql server itself.
The Function or procedure which u had written works fine
with out generating any duplicate values.
Since Select Statment issues a shared lock
and an Update Statment issues an exclusive lock
suppose the same time the two users get the value 10 also
It does not hurt nor give duplicate values since the
Update statment issues an exclusive lock..
therefore please take away explicit lock function in your
query then the query is ok.
For more Information this is from Inside sql serve book
Shared locks are acquired automatically by SQL Server when
data is read. Shared locks can be held on a table, a page,
an index key, or an individual row. Many processes can
hold shared locks on the same data, but no process can
acquire an exclusive lock on data that has a shared lock
on it (unless the process requesting the exclusive lock is
the same process as the one holding the shared lock).
Normally, shared locks are released as soon as the data
has been read, but you can change this by using query
hints or a different transaction isolation level.
SQL Server automatically acquires exclusive locks on data
when it is modified by an insert, update, or delete
operation. Only one process at a time can hold an
exclusive lock on a particular data resource; in fact, as
you'll see when we discuss lock compatibility, no locks of
any kind can be acquired by a process if another process
has the requested data resource exclusively locked.
Exclusive locks are held until the end of the transaction.
This means that the changed data is normally not available
to any other process until the current transaction commits
or rolls back. Other processes can decide to read
exclusively locked data by using query hints.
contains an integer
SQL_Latin1_General_CP1_CI_AS NOT NULL ,
SQL_Latin1_General_CP1_CI_AS NOT NULL
value I am looking
procedure would generate
obtain the AppID