SYBASE 17 - Insert result set into Temp Table from sp_columns

216 Views Asked by At

I'm new to Sybase but familiar with MS SQL Server. I'm trying to take the results from sp_columns and put it into a temp table. What is the proper syntax for this?

So far I have the below code but it's not working (error below).

CALL sp_columns('TableName')( et_result => #ColumnListing) WITH OVERVIEW;

enter image description here

Thanks in advance!

--Edited to include error detail and code.

2

There are 2 best solutions below

1
access_granted On
insert into #temp_table select so.name table_name, sc.name column_name
from syscolumns sc
  , sysobjects so
where sc.id = so.id

Expand the output column list at your own imperative

0
markp-fuso On

WITH OVERVIEW does not appear to be a part of the (SAP) SQL Anywhere CALL statement [and I couldn't find anything that comes anywhere close to whatever this is: ( et_result => #ColumnListing)].

I did find a reference to WITH OVERVIEW in the (SAP) HANA CALL statement but (of course) this is not useful in a SQL Anywhere context.

Looking through the (SAP) SQL Anywhere SQL Reference manual - SQL Statements I couldn't find an exact match on your requirement but I was able to combine the specs for the INSERT Statement + SELECT Statement + FROM Clause to generate this:

INSERT into #ColumnListing
select * from sp_columns('CatalogElement')

NOTE: tested successfully in a (SAP) SQL Anywhere v 17.0.9.4899 database