Sybase Question:

How can I execute dynamic SQL with ASE in Sybase?

Tweet Share WhatsApp

Answer:

Adaptive Server Enterprise: System 12

ASE 12 supports dynamic SQL, allowing the following:

declare @sqlstring varchar(255)
select @sqlstring = "select count(*) from master..sysobjects"
exec (@sqlstring)
go


Adaptive Server Enterprise: 11.5 and 11.9

* Firstly define your local server to be a remote server using
sp_addserver LOCALSRV,sql_server[,INTERFACENAME]
go

* Enable CIS
sp_configure "enable cis",1
go

* Finally, use sp_remotesql, sending the sql to the server defined in point 1.
declare @sqlstring varchar(255)
select @sqlstring = "select count(*) from master..sysobjects"
sp_remotesql LOCALSRV,@sqlstring
go

Download Sybase PDF Read All 123 Sybase Questions
Previous QuestionNext Question
Which version of Open Client works with which ASE in Sybase?How do I configure Identities in Sybase?