【问题标题】:Sybase, execute string as sql querySybase,将字符串作为sql查询执行
【发布时间】:2011-04-15 17:57:00
【问题描述】:

在 Sybase SQL 中,我想执行一个包含 SQL 的字符串。

我希望这样的东西可以工作

declare @exec_str char(100)
select @exec_str = "select 1"
execute @exec_str
go

来自documentation of the exec command

执行 |执行

is used to execute a stored procedure or an extended stored

程序 (ESP)。这个关键字是 如果有多个是必要的 批处理中的语句。

execute 也用于执行包含 Transact-SQL 的字符串。

但是我上面的例子给出了一个错误。我做错了吗?

【问题讨论】:

    标签: string sybase execute


    【解决方案1】:

    你需要括号:

    execute ( @exec_str )
    

    【讨论】:

      猜你喜欢
      • 2017-03-29
      • 1970-01-01
      • 1970-01-01
      • 2014-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      相关资源
      最近更新 更多