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 |
|
ikhuram
Starting Member
28 Posts |
Posted - 2004-05-28 : 00:59:10
|
| If a table has dynamic number of columns. And we want to add a computed column on the basis of these dynamic columns. How will this be done. e.g., Table A could have 2 or 2000 columns. Now we want to add a computed column like(A.Col1 * B.quantity) as CThe problem is we dont know the names of the dynamic columns, and secondly do we have to mention each time the column name, its too hectic if there are 2000 columns. One way is to open cursor on the column name of this table from syscolumns and then do the processing but it will slow down the system. I am looking for a better tip/way |
|
|
Werwolf13
Starting Member
7 Posts |
Posted - 2004-05-28 : 03:52:20
|
| Hi. Do U really need to create computed column? Maybe U r not... becasue if U r going to use these in some query, U better compute'em directly i Ur query. Tell me if I am wrong...Anyway... U must not use cursor to populate the column... Just use the construction of following:UPDATE YourTableSET YuorNewCulumnName = Col1*Col2 |
 |
|
|
|
|
|