select 1 a into #tselect * from #tdrop table #tselect 2 b into #t

解决方案 »

  1.   

    select 1 a into #tselect * from #tdrop table #t
    goselect 2 b into #tdrop table #t
      

  2.   

    drop table #t
    select 2 b into #t
    你dr0p 掉了 #t 
    哪來 #t 了呢?
      

  3.   

    select top 1 1 as 列名 into #t from syscolumnsselect * from #tdrop table #t
      

  4.   

    這樣OKselect 1 a into #tselect * from #tdrop table #t
    GO
    select 2 b into #t
      

  5.   

    select 1 a into #tselect * from #tdrop table #t 
    go 
    select 2 b into #t这样就没问题了,不太清楚为什么
      

  6.   

    存储过程中不能用go,可以考虑在动态SQL中处理。
      

  7.   

    存储过程里面的GO代表存储过程结束,所以只能有一个GO.
      

  8.   

    在一个存储过程里面能够使用多个go吗
    --------
    不能。存储过程的代码是creae proc与第一个go之间的部分。
    一个存储过程是编译成一个执行计划,而一个批处理会编译为N(N>=1)个执行计划,
    所以存储过程不可能分成两个批处理。我的理解。
      

  9.   

    GO 不是 Transact-SQL 语句;它是 sqlcmd 和 osql 实用工具以及 SQL Server Management Studio 代码编辑器识别的命令。SQL Server 实用工具将 GO 解释为应该向 SQL Server 实例发送当前批 Transact-SQL 语句的信号。当前批语句由上一 GO 命令后输入的所有语句组成,如果是第一条 GO 命令,则由即席会话或脚本开始后输入的所有语句组成。 GO 命令和 Transact-SQL 语句不能在同一行中