Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Server Execution Timeout Expired

SQL Server Execution Timeout Expired

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
2 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    idkd
    wrote on last edited by
    #1

    I have a situation where when I run this stored proc on the live database I get a timeout error. if I copy the two tables into a different dead database where there are no transactions happening, then I get a result instantly the table Jn has over 2 million records.

    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

    has not helped. Even WITH NOLOCK has not helped. any ideas pls ? stored proc is below

    create PROCEDURE [dbo].[mysp]
    @sRefDateFrom AS CHAR(8) , @sRefDateTo AS CHAR(8) -- Dates are expected in 'YYYYMMDD'
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
    SELECT A.FormatCode, A.AcctName , SUM(J.Debit) AS Debit, SUM (J.Credit) AS Credit
    FROM JN J
    JOIN AC A
    ON A.AcctCode = J.Account
    WHERE J.RefDate >= @sRefDateFrom
    AND J.RefDate <= @sRefDateTo
    GROUP BY A.FormatCode , A.AcctName
    ORDER BY A.FormatCode
    END

    S 1 Reply Last reply
    0
    • I idkd

      I have a situation where when I run this stored proc on the live database I get a timeout error. if I copy the two tables into a different dead database where there are no transactions happening, then I get a result instantly the table Jn has over 2 million records.

      SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

      has not helped. Even WITH NOLOCK has not helped. any ideas pls ? stored proc is below

      create PROCEDURE [dbo].[mysp]
      @sRefDateFrom AS CHAR(8) , @sRefDateTo AS CHAR(8) -- Dates are expected in 'YYYYMMDD'
      AS
      BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
      SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
      SELECT A.FormatCode, A.AcctName , SUM(J.Debit) AS Debit, SUM (J.Credit) AS Credit
      FROM JN J
      JOIN AC A
      ON A.AcctCode = J.Account
      WHERE J.RefDate >= @sRefDateFrom
      AND J.RefDate <= @sRefDateTo
      GROUP BY A.FormatCode , A.AcctName
      ORDER BY A.FormatCode
      END

      S Offline
      S Offline
      SeanChupas
      wrote on last edited by
      #2

      Make sure you have an index on RefDate. Probably another one on FormatCode and AcctName. Beyond that, you need to use the database tools to track down which part is taking the most time. If it is Microsoft Sql Server then you can use the Estimated Execution Plan and other tools.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups