开发者

Sybase, execute string as sql query

开发者 https://www.devze.com 2023-01-17 16:30 出处:网络
In Sybase SQL, I would like to execute a String containing SQL. I would expect something like this to work

In Sybase SQL, I would like to execute a String containing SQL.

I would expect something like this to work

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

开发者_StackOverflowfrom the documentation of the exec command

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.

However my above example gives an error. Am I doing something wrong?


You need bracketing:

execute ( @exec_str )
0

精彩评论

暂无评论...
验证码 换一张
取 消