return column names with sql2gms

Hello,
I want to use sql2gms to run a query that gives me the column names in a table. Running sql queries through gams with sql2gms, if I select columns from a table I do not see the column names in the output file.

That is, I run code like

$set aQuery aQuery.txt
$onecho > %aQuery%
C=filedsn=%directory%aConnection.dsn
O=%directory%\Output.inc
Q=SELECT * FROM TABLENAME
$offecho
$call =sql2gms @%aQuery%

I get all of the values from the table TABLENAME, but I do not get any header row showing the column names. How can I get the column names in my query? Any insight would be appreciated.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

\

Eric,
This might depend on the actual DBMS you are using. The following query works fine with mysql but not with Microsoft Access:

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ‘database_name’ AND TABLE_NAME = ‘table_name’;

Change database_name and table_name to the names you are using. Hopefully this works for you.

Best
Clemens


On 7/30/2013 12:01 AM, Eric Krall wrote:

Hello,
I want to use sql2gms to run a query that gives me the column names in a table. Running sql queries through gams with sql2gms, if I select columns from a table I do not see the column names in the output file.

That is, I run code like

$set aQuery aQuery.txt
$onecho > %aQuery%
C=filedsn=%directory%aConnection.dsn
O=%directory%\Output.inc
Q=SELECT * FROM TABLENAME
$offecho
$call =sql2gms @%aQuery%

I get all of the values from the table TABLENAME, but I do not get any header row showing the column names. How can I get the column names in my query? Any insight would be appreciated.

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.


\