System. Data. sqlclient. sqlexception: exceeds the maximum number of nested layers of stored procedures, functions, triggers, or views (the maximum number of layers is 32 ).
First, let's look at the nested definition:
For example:
Nested Layer 1
Select * From
( Select * From Student) As A
Nested Layer 2
Select * From
( Select * From
( Select * From Student) As A) As B
Common Errors:
1 . Nested call in the trigger
Create Trigger Monistudentinsert
On Student
For Insert , Update
As
Begin
Update Student Set Instime = Getdate ()
Where Sid = ' 59e89064-8ef9-450-8293-7f6a3f97d9af '
End
Go
Solution: For Insert , Update Removed from Update.
2 . After the stored procedure is defined, go is not added (usually displayed when multiple SQL statements are executed once)
For example:
If Exists ( Select * From DBO. sysobjects Where ID = Object_id (N ' [DBO]. [profu_getstudentinfo] ' ) And Type In (N ' P ' , N ' PC ' ))
Drop Procedure Profu_getstudentinfo
Go
Create Procedure Profu_getstudentinfo
@ Sid Nvarchar ( 20 )
As
Begin
Select Distinct Sname, sex
From Student
Where Sid = @ Sid
End
Exec Profu_getstudentinfo ' 10001 '
Go
Solution:
Set
End
Exec Profu_getstudentinfo ' 10001 '
Go
Changed:
End
Go
Exec Profu_getstudentinfo ' 10001 '
That is, after defining the stored procedure, add Go Statement.