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.
| Author |
Topic |
|
nshankar
Starting Member
9 Posts |
Posted - 2008-02-19 : 01:19:42
|
| Hii want to retrieve the column name using query. i am implementing a cursor to update on the particular table with respect the column names. i dont want to place the column names as static.thanks in advance |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-19 : 02:02:59
|
| Please make your requirement clear. Can you supplement your requirement with your tables structure and sample data please? |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-19 : 04:06:25
|
| Have you considered using INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS?Jack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
Abu-Dina
Posting Yak Master
206 Posts |
Posted - 2008-02-19 : 06:52:16
|
As jackv sugegsted, use the system views provided to you by SQL Server. Also, try and avoid using cursors in your code. A WHILE loop will also do the same job for you.Something like this might work:create table #myColumns(ColumnHeader varchar(50))insert into #myColumns(ColumnHeader)select COLUMN_NAMEfrom INFORMATION_SCHEMA.COLUMNSwhere TABLE_NAME = 'myTable' Good Luck! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-19 : 06:55:28
|
| You can probably write a stored proc which takes column name as a param and use system catalog views to check for tables containing this column and perform updation on a while loop for each records returned from view. |
 |
|
|
|
|
|