zoukankan      html  css  js  c++  java
  • An INSERT EXEC statement cannot be nested.

    今天开发同事有咨询问题,报错An INSERT EXEC statement cannot be nested.

    经过在网上查询,最终找到解决方案,具体见:http://www.sommarskog.se/share_data.html#INSERTEXEC

    Demo如下:

    use demo 
    go 
    alter proc usp_a @a int 
    as 
    create table #a(id int,editdt datetime) 
    insert into #a 
            select @a,getdate() 
    select * from #a   
    
    alter proc usp_b 
    as 
    create table #c (id int,editdt datetime) 
    insert into #c exec usp_a '2' 
    select * from #c 
    
    
    create table #d (id int,editdt datetime) 
    insert into #d exec usp_b 
    select * from #d
    

      

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

    可以采用如下的方式解决:

    use demo
    go
    alter proc usp_c @a int
    as
    insert #c select @a,getdate()

    alter proc usp_d
    as
    create table #c(id int,editdt datetime)
    exec usp_c '2'
    select * from #c

    create table #e (id int,editdt datetime)
    insert into #e exec usp_d
    select * from #e

      

  • 相关阅读:
    js Array的方法及属性总结
    js 继承
    js 判断数据类型
    序列化和反序列化
    express 常用方法和插件
    node 常用的对象
    node.js 守护进程
    CentOS7安装Python3.8.1和ansible
    MAC终端终极美化方案
    Linux之top命令详解
  • 原文地址:https://www.cnblogs.com/Wison-Ho/p/3993169.html
Copyright © 2011-2022 走看看