Solution: 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 ).

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.