Finding Column Labels corresponding to specific columns in sql server 2005
I am facing problem, finding out specific column names. I am using SQL Server 2005 and am coding in struts 2 framework.
Here is what needs to be done:
I want to find out the column names which have a particular value in a particular row.
For example: In a row in employee table, if the 开发者_开发问答value of a particular column is "true", I want to know the column name.
I know in SQL server we can access all the column names of a table using this query:
select column_name from information_schema.columns where table_name = 'table's name'
but I am not able to fulfill my purpose.
I guess I have defined my issue clearly, if there is anything that I missed out please tell.
Thanks!!
I'll assume you're not using an ORM, and that you're using JDBC, although unfortunately you don't say how you're getting data from the database.
You need to use ResultSetMetaData
if you're using JDBC. from which you can get the name of a column by its index.
精彩评论