Primary key has null values when select * from tbl (nolock)

  • Hi,

    I have executed "select * from tbl" from QA. Due to locks, it didn't show any records.  Then I issued "select * from tbl (nolock)" and it showed all the rows and some of the rows had null values in the PK column. I check for the processes and found deadlock in one process and killed it. Then I issued "select * from tbl" and it showed all the values.  Meanwhile the client programs, had accessed the PK values.

    Any idea why did it happen?

    Thanks,

    R.Prakash


    Kindest Regards,

    R

  • The no lock hint is equivalent to running in read uncommitted isolation level.  This means that you could have dirty reads.  I would guess that the nulls came from uncommitted data.

     

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • I agree. I would be very careful about using (NOLOCK) in production if your data consistency actually matters... According to me people put in (NOLOCK) too often without thinking what it could cause.

    Hans

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply