how to put nolock with tabel alies

  • hi,

    which one is good way of putting nolock

    other think is

    Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    above was given in https://msdn.microsoft.com/en-us/library/ms187373.aspx

    is it applicable to single hints also.

    1) select * from customer cus(nolock)

    join salesorder s(nolock) on cus.custid = s.custid

    2) select * from customer(nolock) cus

    join salesorder(nolock) s on cus.custid = s.custid

    yours sincerley

  • Answer withdrawn because I prefer not to help people with interview questions.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • rajemessage 14195 (8/6/2016)


    hi,

    which one is good way of putting nolock

    other think is

    Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    above was given in https://msdn.microsoft.com/en-us/library/ms187373.aspx

    is it applicable to single hints also.

    1) select * from customer cus(nolock)

    join salesorder s(nolock) on cus.custid = s.custid

    2) select * from customer(nolock) cus

    join salesorder(nolock) s on cus.custid = s.custid

    yours sincerley

    My question is why use nolock? Do you understand what it means?

    😎

  • rajemessage 14195 (8/6/2016)


    hi,

    which one is good way of putting nolock

    other think is

    Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    above was given in https://msdn.microsoft.com/en-us/library/ms187373.aspx

    is it applicable to single hints also.

    1) select * from customer cus(nolock)

    join salesorder s(nolock) on cus.custid = s.custid

    2) select * from customer(nolock) cus

    join salesorder(nolock) s on cus.custid = s.custid

    yours sincerley

    Neither. The use of the NOLOCK hint is most stupid and can play hell with data and the application. People use it to try to overcome performance problems that shouldn't exist to begin with.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Talking about interviews, I did one last week. The question that tipped the interview from 'maybe' to 'no' was when I asked about the cause of deadlocks and he replied that deadlocks were caused when multiple people queried the same table without using the nolock hint.

    So, if this is an interview question, maybe it's a trick question and you're supposed to react with horror and explain why you'd never use nolock so broadly.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

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