Sybase,执行字符串作为SQL查询

7
在Sybase SQL中,我想执行一个包含SQL语句的字符串。我期望类似这样的内容能够运行。
declare @exec_str char(100)
select @exec_str = "select 1"
execute @exec_str
go

exec命令的文档中可以得知以下信息:

execute | exec

is used to execute a stored procedure or an extended stored

procedure (ESP). This keyword is necessary if there are multiple statements in the batch.

execute is also used to execute a string containing Transact-SQL.

但是我上面的例子报错了。我做错了什么吗?

1个回答

9
你需要使用括号来区分不同的内容:
execute ( @exec_str )

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接