Re: Locking...



On Wed, 22 Nov 2006 08:44:18 -0500, Rogers wrote:

Can any one give me any URL where I can find the locking Hint with example.

I have a two query in one my stored procedure and in the that its returning
session ID to users like.

Set @SessionID = (Select TOP 1 SessionID from Session)

Hi Rogers,

Are you aware that the result of a TOP clause without accompanying ORDER
BY is completely undefined?

You definitely need to make sure to acquire an exclusive lock, or at
least an update lock (as you do with the UPDLOCK hint in your revised
code) to make sure that nobody else gets the same SessionID. Also, do
take a look at the READPAST hint as Roger advises. If you are doing what
I think you are doing, you'll benefit from it.

--
Hugo Kornelis, SQL Server MVP
.



Relevant Pages

  • Re: Performance problem on initial call of stored procedure
    ... The initial call to a stored procedure that performs 3 sql select ... If you let the session set for around 5 minutes, ... The websphere configuration is running on a Windows NT machine and, ...
    (comp.sys.ibm.as400.misc)
  • Re: Performance problem on initial call of stored procedure
    ... The initial call to a stored procedure that performs 3 sql select ... If you let the session set for around 5 minutes, ... The websphere configuration is running on a Windows NT machine and, ...
    (comp.sys.ibm.as400.misc)
  • RE: Perms on Tempdb?
    ... be saved from one session of SQL Server to another. ... A local temporary table created in a stored procedure is dropped ... created the table ends and all other tasks have stopped referencing them. ...
    (microsoft.public.sqlserver.security)
  • Re: Perms on Tempdb?
    ... > be saved from one session of SQL Server to another. ... > automatically when the stored procedure completes. ... > created the table ends and all other tasks have stopped referencing them. ... > of a single Transact-SQL statement. ...
    (microsoft.public.sqlserver.security)
  • Re: Session variable vs. Stored Proc
    ... information from page one in hidden form fields, ... probably still better to store in session & run one stored proc ... > procedure OR would it be better to run a stored procedure the first page ...
    (microsoft.public.dotnet.framework.aspnet)

Loading