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 |
|
metser
Starting Member
27 Posts |
Posted - 2005-07-03 : 12:53:24
|
| Hello.I have a table (SQL Server), with about 1000 rows. I need to update each row so column B (currently NULL for each row) will hold the value of columns A (an auto-increment field for that row) + a constant string. To clarify, at the end I need, for each row, to have column B = "ABC" + that row's UID.What is the correct update query? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-07-03 : 13:55:33
|
| Might ask why you would want to do this?update tblset B = 'ABC' + convert(varchar(20),A)Have a look at computed columns and also consider doing it for rpesentation and not persisting the data at all - or just the constatnt if that is to change for later rows.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
metser
Starting Member
27 Posts |
Posted - 2005-07-03 : 14:15:43
|
| Hello. Thank you for you response.The reason for my question - I am working on a DB which holds resellers data, and I need a UID for each one, which they will use when purchasing products from different vendors. For this UID I am using the table's UID plus, for now, a constant set of characters. However - this set of characters may change in the future. I wanted to save this information in a separate column so I can index it for faster search option.Isn't this the way to go? |
 |
|
|
metser
Starting Member
27 Posts |
Posted - 2005-07-03 : 14:19:33
|
| Just to clarify my previous post - the constant may be changed for each row. This is only the initial value...Thanks again. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-07-03 : 14:52:01
|
| Well you could save the characters in a column which will define the row type then index the that column + identity. It will save having to hold the identity value twice in the row.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
metser
Starting Member
27 Posts |
Posted - 2005-07-03 : 15:31:37
|
| Great. Then this is the solution I'll use!Thanks again. |
 |
|
|
|
|
|