Search code examples
c#cachingsqlexception

Sql execption: Maximum stored procedure..level exceeded


This is the first time im using caches. I set my local cache to true in my webconfig.When i try to run my login page is gives the following error

System.Data.SqlClient.SqlException occurred HResult=0x80131904 Message=Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32). Source=.Net SqlClient Data Provider StackTrace:

it throws the error on the following code

lock (lastlevelLock)
        {
            DataSet retval = new DataSet();
            if (UseLocalCache)
            {
                retval =Data.DataRepository.Provider.GetDetailsAll(); // this is where the error comes in

                if (retval == null)
                    retval = new DataSet();
            }
            else

what am i doing wrong? because the exact same code and db works fine on other machines.I did look at the other similar errors mention on stackflow but nothing helped.

    --WITH ENCRYPTION
AS
BEGIN

;WITH cte AS (
        SELECT  //do selection
        FROM Table g WITH(NOLOCK)
    )
    SELECT //do selection
    INTO #cte
    FROM cte c
        INNER JOIN list.Type gt WITH(NOLOCK) ON c.TypeId = gt.TypeID
        INNER JOIN table.crumb br WITH(NOLOCK) ON c.ID = br.ID
    ORDER BY Lev
    SELECT 
    // select columns
        NULL AS ResultExpected
    INTO #TempGame
    FROM #cte tg
        JOIN list.Type gt WITH(NOLOCK) ON tg.TypeID = gt.TypeID
    WHERE tg.ID IN (
        SELECT ID FROM table2 WITH(NOLOCK)
        WHERE ID = tg.ID

        )


    SELECT 
        //select columns
    INTO #Temp2
    FROM tanbe2 m WITH(NOLOCK)
        INNER JOIN table g WITH(NOLOCK) ON m.ID = g.ID
        //perform all joins
    WHERE m.ID IN (SELECT ID FROM #Temp)

         GETDATE() < ISNULL(m.ResultDateTime, m.ResultExpected) 


    SELECT * FROM #Temp
    SELECT * FROM #Temp2
    ORDER BY ResultExpected

    DROP TABLE #cte
    DROP TABLE #Temp
    DROP TABLE #Temp2


END
GO

Solution

  • After searching and trying different solutions for multiple hours,i finally just restored the db AGAIN and it seemed to work.