Sybase, execute a string as sql query

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 

from the exec command documentation

execute | Exec

 is used to execute a stored procedure or an extended stored 

(ESP). This keyword is necessary if there are several in the package.

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

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

+7
string sybase execute
source share
1 answer

You need bracketing:

 execute ( @exec_str ) 
+8
source share

All Articles