Skip to Content
avatar image
Former Member

Command No Lock statement

Hi

I have a Command running in a report that is taking a long time to run. I realise there could be a number of reasons for this (including poor Command writing skills!) but I have seen the statement of No Locks used somewhere before in a Command but cannot remember the syntax - any pointers please as I think this may help in this instance?

Thanks in advance for your help

Jon

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 07, 2017 at 04:55 PM

    Only used in SQL server, syntax is

    SELECT * FROM Tablename WITH (NOLOCK) WHERE field condition

    use with care as not really appropriate for high volume transaction scenarios

    http://stackoverflow.com/questions/686724/sql-server-when-should-you-use-with-nolock

    Ian

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 07, 2017 at 03:47 PM

    Hi Jon,

    What Database are reporting off of?

    Also, how long does that SQL take to run directly against the database via a database client tool?

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 07, 2017 at 05:38 PM

    If you are having performance issues I suggest using a Stored Procedure, that way the Server is doing all of the work and sending just the results to CR for formatting. And it's safer also.

    Don

    Add comment
    10|10000 characters needed characters exceeded