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. Nesting Limit

Nesting Limit

Scheduled Pinned Locked Moved Database
databasequestionsaleshelp
4 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Andy_L_J
    wrote on last edited by
    #1

    Assume @Code is a three character prefix, ie: AUS Why does this break:

    DECLARE @TEMP VARCHAR(7) =
    (SELECT TOP 1 CustCode
    FROM Customer
    WHERE LEFT(CustCode, 3) = @Code)

    with the following error?

    Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

    I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

    M 1 Reply Last reply
    0
    • A Andy_L_J

      Assume @Code is a three character prefix, ie: AUS Why does this break:

      DECLARE @TEMP VARCHAR(7) =
      (SELECT TOP 1 CustCode
      FROM Customer
      WHERE LEFT(CustCode, 3) = @Code)

      with the following error?

      Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

      I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I suspect there are more than 1 record matching your @code filter and you are trying to stuff more than 1 record into @Temp. Nope - thats not it, you have top 1. It works for me on sql server 2008 R2. I used this

      DECLARE
      @Code VARCHAR(3)

      SET @Code = '103'

      DECLARE @TEMP VARCHAR(7) =
      (SELECT TOP 1 filename
      FROM dbo.ImportFiles
      WHERE LEFT(filename, 3) = @Code)

      SELECT @Temp

      Which gives me the first 7 characters of the filename (all the file names start with 103). Changing @Code returns null

      Never underestimate the power of human stupidity RAH

      A 1 Reply Last reply
      0
      • M Mycroft Holmes

        I suspect there are more than 1 record matching your @code filter and you are trying to stuff more than 1 record into @Temp. Nope - thats not it, you have top 1. It works for me on sql server 2008 R2. I used this

        DECLARE
        @Code VARCHAR(3)

        SET @Code = '103'

        DECLARE @TEMP VARCHAR(7) =
        (SELECT TOP 1 filename
        FROM dbo.ImportFiles
        WHERE LEFT(filename, 3) = @Code)

        SELECT @Temp

        Which gives me the first 7 characters of the filename (all the file names start with 103). Changing @Code returns null

        Never underestimate the power of human stupidity RAH

        A Offline
        A Offline
        Andy_L_J
        wrote on last edited by
        #3

        Thanks for looking Mycroft - seems the issue is a calculated field (CustCode) that is part of the table definition.

        CREATE TABLE Customer(
        ...
        CustCode AS udf_GetCustCode(@Name),
        ...

        I think this needs to be calculated as a udf during the INSERT.

        I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

        M 1 Reply Last reply
        0
        • A Andy_L_J

          Thanks for looking Mycroft - seems the issue is a calculated field (CustCode) that is part of the table definition.

          CREATE TABLE Customer(
          ...
          CustCode AS udf_GetCustCode(@Name),
          ...

          I think this needs to be calculated as a udf during the INSERT.

          I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Andy_L_J wrote:

          seems the issue is a calculated field (CustCode) that is part of the table definition.

          Probably fired off by a trigger - triggers how to completely fuck your database.

          Never underestimate the power of human stupidity RAH

          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