开发者

Equivalent to sp_executesql in Sybase

What's the equivalent to sp_executesql of Sql开发者_如何转开发 Server in sybase.


I think exec() is what you're looking for. See http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands56.htm.


@jasir: the limitation to 255 characters results from your procedure definition. Isn't possible to extend this limit by defining e.g. varchar(1024)?

ASE Refrence Manual 15.7 (http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1572/html/commands/X30305.htm) states for command execute:

string is a literal string containing part of a Transact-SQL command to execute. There are no restrictions to the number of characters supplied with the literal string.

However, sometimes a system on top of sybase (e.g. Kondor+, a product for financial markets uses ASE 15.x as DB) may set limits. In this Kondor+ it is not possible to use

exec( @SQLQuery) 

in its so called OpenReport (a stored procedure), if the variable @SQLQuery exceeds 256 characters.


For older ASE, you can use this workaround:

There is stored procedure sp_remotesql. You can use it to run query on local server too, you just have to local server to servers:

sp_addserver local, NULL, <servername>

Where <servername> is name of local server (from sql.ini).

You can add shortcut procedure for running sql:

create procedure sp_exec_dynsql @p_cmd varchar(255)
as
begin
   exec sp_remotesql "local", @p_cmd
end

Unfortunatelly, you are limited to 255 characters in your sql.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜