Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get table column name at run time

Author  Topic 

ehsandar
Starting Member

4 Posts

Posted - 2008-06-18 : 02:46:24
I want to get a table column name at run time through query. Can any one help me.

ehsan ulhaq dar

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-18 : 02:50:25
What do you mean at 'run time'? Could you please explain further.
Go to Top of Page

ehsandar
Starting Member

4 Posts

Posted - 2008-06-18 : 04:59:54
Actually i am working in jsp. In jsp page I got table name as a parameter and show its all column in jsp page.

ehsan ulhaq dar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 05:07:35
just use this
"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =" & YourTableNameParameter
Go to Top of Page

ehsandar
Starting Member

4 Posts

Posted - 2008-06-18 : 07:03:07
I use this qry "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = COUNTRY" in SQL Server it give "error Invalid column name 'COUNTRY'."

ehsan ulhaq dar
Go to Top of Page

ehsandar
Starting Member

4 Posts

Posted - 2008-06-18 : 07:18:54
I got the error cause, table name should be single colon i.e. 'COUNTRY'. Thanks visakh16 for your help. GOD bless you.

ehsan ulhaq dar
Go to Top of Page
   

- Advertisement -