Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
i need to retrieve column names from a database, when a table name provide as a parameter to the sql query.
SQL
select c.name as SC_DATA_COL_NAME  from sys.tables v,sys.columns c where v.object_id=c.object_id and upper(v.name)=upper(@name) 

here @name is used as a parameter

above query works fine in sql server but not in DB2, please give some suggestion to create a query which runs on DB2.
Posted
Updated 12-Sep-11 2:41am
v2

SELECT NAME AS SC_DATA_COL_NAME FROM SYSCOLUMNS WHERE TBNAME = @name
 
Share this answer
 
I changed solution 1 little bit then it works fine

SELECT DISTINCT COLUMN_NAME FROM SYSIBM.COLUMNS
WHERE TABLE_NAME=@name
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900