【问题标题】:Incorrect syntax near the keyword 'end'关键字“end”附近的语法不正确
【发布时间】:2013-03-14 14:35:04
【问题描述】:

谁能帮帮我?

不知道为什么下面的SQL会报语法错误:

if not exists (select 1 from sysobjects where type='U' and name='pg_result')
    create table pg_result (parent char(10), child char(10)) 
else
    delete from pg_result
end if

我收到以下错误:

[错误] 脚本行:141-146

关键字“end”附近的语法不正确。

消息:156,级别:15,状态:2

服务器:SYBDEV,线路:5

我在跑步:

Adaptive Server Enterprise/12.5.4/EBF 16785 ESD#10/P/Sun_svr4/OS 5.8/ase1254/2159/64-bit/FBO/Mon Nov 2 13:08:08 2009

有什么想法吗?

【问题讨论】:

    标签: sql sap-ase


    【解决方案1】:

    如果您不使用begin,则不需要end

    【讨论】:

      【解决方案2】:

      试试

      if not exists (select 1 from sysobjects where type='U' and name='pg_result')
          create table pg_result (parent char(10), child char(10)) 
      else
          delete from pg_result
      

      if not exists (select 1 from sysobjects where type='U' and name='pg_result')
      begin
          create table pg_result (parent char(10), child char(10)) 
      end
      else
      begin
          delete from pg_result
      end
      

      http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.commands/html/commands/commands61.htm

      【讨论】:

        猜你喜欢
        • 2011-04-07
        • 2016-06-08
        • 2013-12-16
        • 2015-06-12
        • 2017-11-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-16
        相关资源
        最近更新 更多