Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3486056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:58:57+00:00 2026-05-18T10:58:57+00:00

I have upgraded from SQL Server 2005 to 2008. I remember that in 2005,

  • 0

I have upgraded from SQL Server 2005 to 2008. I remember that in 2005, ROWLOCK simply did not work and I had to use PAGELOCK or XLOCK to achieve any type of actual locking. I know a reader of this will ask “what did you do wrong?” Nothing. I conclusively proved that I could edit a “ROWLOCKED” row, but couldn’t if I escalated the lock level. I haven’t had a chance to see if this works in SQL 2008. My first question is has anyone come across this issue in 2008?

My second question is as follows. I want to test if a value exists and if so, perform an update on relevant columns, rather than an insert of the whole row. This means that if the row is found it needs to be locked as a maintenance procedure could delete this row mid-process, causing an error.

To illustrate the principle, will the following code work?

BEGIN TRAN

SELECT      ProfileID
FROM        dbo.UseSessions
WITH        (ROWLOCK)
WHERE       (ProfileID = @ProfileID)
OPTION      (OPTIMIZE FOR (@ProfileID UNKNOWN))

if @@ROWCOUNT = 0 begin
    INSERT INTO dbo.UserSessions (ProfileID, SessionID)
    VALUES      (@ProfileID, @SessionID)
end else begin
    UPDATE      dbo.UserSessions
    SET         SessionID = @SessionID, Created = GETDATE()
    WHERE       (ProfileID = @ProfileID)
end

COMMIT TRAN
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:58:57+00:00Added an answer on May 18, 2026 at 10:58 am

    An explanation…

    • ROWLOCK/PAGELOCK is granularity
    • XLOCK is mode

    Granularity and isolation level and mode are orthogonal.

    • Granularity = what is locked = row, page, table (PAGLOCK, ROWLOCK, TABLOCK)

    • Isolation Level = lock duration, concurrency (HOLDLOCK, READCOMMITTED, REPEATABLEREAD, SERIALIZABLE)

    • Mode = sharing/exclusivity (UPDLOCK, XLOCK)

    • “combined” eg NOLOCK, TABLOCKX

    XLOCK would have locked the row exclusively as you want. ROWLOCK/PAGELOCK wouldn’t have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We just upgraded our SQL Server 2005 to SQL server 2008 R2 and noticed
I have an app that I've upgraded from 3.5 to 4.0. But not all
All - I have recently upgraded our production environment from Sql Server Reporting Services
I've got a database from SQL Server 2005 that I am programmatically attaching to
I have upgraded a MS Visual Studio Application from VS 2003 to VS 2008
What issues or refactoring did you have to do when you upgraded from ASP.NET
I have just upgraded our company's domain controller from NT 4.0 to Windows 2008
I have just upgraded my server 2003 to serrver 2008. As I write this,
I recently upgraded VS 2005 to VS 2008. Unfortunately I have a very basic
We have a Sql Server 2000 database application that needs to update our applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.