Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6646335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:24:14+00:00 2026-05-26T00:24:14+00:00

I have a procedure called Insert and the code looks like: Create procedure Gen_insert

  • 0

I have a procedure called Insert and the code looks like:

Create procedure Gen_insert
As
BEGIN


create table #temp
 ( insert_stmt varchar(max) ) 
 insert into #temp  
EXEC Generate_Insert @Table = 'Admin'

 insert into #temp  
EXEC Generate_Insert @Table = 'Impas'

 insert into #temp 
 EXEC Generate_Insert @Table = 'Asui'

 insert into #temp 
 EXEC Generate_Insert @Table = 'Alstd'  

select * from #temp 

End

When I execute it I am getting following error:

Msg 8164, Level 16, State 1, Procedure Gen_Insert, Line 73
An INSERT EXEC statement cannot be nested.

Can anyone help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:24:15+00:00Added an answer on May 26, 2026 at 12:24 am

    An INSERT EXEC statement cannot be nested. The error message is quite clear. You are nesting INSERT … EXEC. statements. Either the procedures you call (Generate_Insert) use again INSERT … EXEC or the caller of insert procedure uses it in an INSERT … EXEC. Only you can find which is the case. As a rule of thumb, INSERT … EXEC should be avoided, because of this and other problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |
I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT
I have a stored procedure in SQL server that looks something like this: insert
I have a stored Procedure called Active and the code is: CREATE PROCEDURE dbo.Active
I'd like to have NHibernate call a stored procedure when ISession.Get is called to
I have a oracle table called: create table InsertHere( generate_id varchar2(10), name varchar2(100) );
I have a table called Events that I want to insert information to. Here
I have a procedure in Sybase with the following code. begin transaction get_virtual_acc UPDATE
I have a table called pettycash CREATE TABLE `pettycash` ( `pc_id` int(7) NOT NULL
I have a Stored Procedure called spGetOrders which accepts a few parameters: @startdate and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.