query problem

  • Respected all

    I have some problem regarding query

    when i use

    select * from tablename

    records shows 0

    select * from tablename with (nolock)

    shows records

    Please Help Me

    thanks

  • gupta1282 (9/30/2009)


    Respected all

    I have some problem regarding query

    when i use

    select * from tablename

    records shows 0

    select * from tablename with (nolock)

    shows records

    Please Help Me

    thanks

    could be a number of reasons, sounds like there is a transaction occuring on that table and you are seeing the commited and uncommited versions of the data

    --------------------------------------------------------------------------------------
    [highlight]Recommended Articles on How to help us help you and[/highlight]
    [highlight]solve commonly asked questions[/highlight]

    Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
    Managing Transaction Logs by Gail Shaw[/url]
    How to post Performance problems by Gail Shaw[/url]
    Help, my database is corrupt. Now what? by Gail Shaw[/url]

  • Basically what's happening is that the table your querying is getting either updated with new records or getting modified by an update statement which locks the database. So when you query the table you see nothing, however when you use nolock you're basically looking at a cached read only version of it. Once the inserts/updates go through you should be able to query it without nolock.

    Please feel free to correct me if I'm wrong.

    Thanks,

    S

    --
    :hehe:

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

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