locked
Selecting data without making any lock RRS feed

  • Question

  • Hi Expert,

      I have a scenarios where if I execute select * from tbl it should display the all the records without waiting to release any lock.  For example suppose I have one table called tbl and one session is updating one records and not committed yet and in other session if i execute select * from table I can see all the records, for that records it can show me older version. but my select statement should not wait to commit another session and also it should not show the modified data.

     


    Regards Vikas Pathak

    Monday, October 26, 2015 9:06 AM

Answers

  • https://msdn.microsoft.com/en-gb/library/ms173763.aspx?f=255&MSPPError=-2147217396

    https://technet.microsoft.com/en-us/library/ms188277%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396


    Thanks, Andrew
    My blog...

    • Proposed as answer by SaravanaC Monday, October 26, 2015 9:35 AM
    • Marked as answer by vikas kumar pathak Friday, November 6, 2015 2:42 PM
    Monday, October 26, 2015 9:14 AM

All replies

  • https://msdn.microsoft.com/en-gb/library/ms173763.aspx?f=255&MSPPError=-2147217396

    https://technet.microsoft.com/en-us/library/ms188277%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396


    Thanks, Andrew
    My blog...

    • Proposed as answer by SaravanaC Monday, October 26, 2015 9:35 AM
    • Marked as answer by vikas kumar pathak Friday, November 6, 2015 2:42 PM
    Monday, October 26, 2015 9:14 AM
  • Hi Vikas,

    You can use Nolock as the query below

    SELECT 
        *
    FROM dbo.person  WITH (NOLOCK)

    Thanks,

    Amit

    Monday, October 26, 2015 9:21 AM
  • Thank you amit for reply but I mentioned above " but my select statement should not wait to commit another session and also it should not show the modified data."

     In case of nolock it will show mw modified and uncommitted records.


    Regards Vikas Pathak

    Tuesday, October 27, 2015 5:48 AM
  • Thank you  Andrew

    Regards Vikas Pathak

    Tuesday, October 27, 2015 5:49 AM