• August 7th, 2010 @ 9:26 PM by Jean-Francois LEBON | Comments Off

    Yes, with Sybase ASE you can get a stored procedure result as rows in a table. The trick is to use proxy tables with an optional clause to the "create existing table" statement to tell ASE the remote object is actually a stored procedure, not a table.

    This requires CIS to be enabled on your ASE:

    1> sp_configure "enable cis",1
    2> go

    Make sure to add a local server to the sysservers system table by adding:

    1> sp_addserver loopback, null, @@servername
    2> go

    Columns list and datatypes must match the description of the procedure’s result set. Consider it when you create your proxy table, otherwise you’ll get errors:

    1> use tempdb
    2> go
    1> create existing table DBDATABASE(
    2> name varchar(35),
    3> db_size varchar(20),
    4> owner varchar(20),
    5> dbid int,
    6> created varchar(35),
    7> status varchar(255)
    8> )
    9> external procedure at "loopback.sybsystemprocs.dbo.sp_helpdb"
    10> go

    Then you can freely query your proxy table to display the stored procedure result set:

    1> select * from DBDATABASE
    2> go

    Or store the result in a table for further processing later on:

    1> select * into #temptable from DBDATABASE
    2> go

    Tags: , , , ,