Page 1 of 1
Columns name from ODBC as data
Posted: Tue Apr 19, 2005 7:47 am
by Luk
Is it possible to catch columns names from SQL querry by ODBC stage and put it i.e. to a file??
Posted: Tue Apr 19, 2005 7:51 am
by Sainath.Srinivasan
Do you mean 'first row is column names' property in seq file?
Posted: Tue Apr 19, 2005 8:15 am
by Luk
no!
I have ODBC stage and I am connecting to MSSQL server. I want to get column names from SQL server as data (in rows) and use them - put into target!
Posted: Tue Apr 19, 2005 8:20 am
by Sainath.Srinivasan
Select the columns as hard-coded value in a separate SQL and call it just before your SQL followed and suffix it with ' UNION '.
Posted: Tue Apr 19, 2005 8:37 am
by mhester
If what you want are the column names from a particular table and stream this as data to a target then you could use a query like the following to select a list of column names -
Code: Select all
select COLUMN_NAME from information_schema.columns
where table_name = 'TABLE_NAME'
Make sure you are connecting to the correct database for what you are doing and replace TABLE_NAME with the table you want or leave out the WHERE and it will return all columns.
Posted: Tue Apr 19, 2005 8:54 am
by Luk
thanks - it is working
Posted: Tue Apr 19, 2005 8:56 am
by Sainath.Srinivasan
Can you post the solution you have successfully implemented so any future search for similar requirements can make use of it.
Posted: Wed Apr 20, 2005 1:23 am
by Luk
Can you post the solution you have successfully implemented so any future search for similar requirements can make use of it.
Sainath - solution is already posted. mhester gave it!!!
Code: Select all
elect COLUMN_NAME from information_schema.columns
where table_name = 'TABLE_NAME'