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 |
|
callmejabba
Starting Member
4 Posts |
Posted - 2005-07-27 : 14:07:43
|
I have been given a small assignment where I have to update certain tables in a database as to get rid of sensitive information (we are sending a copy of the database to an outside contractor). Now I know how to update a table but there is a small twist. Lets say there is a key in the table that is userId, lets say its 001 for one of the records. Now say there is another column called address. I have to update this table so that it says 'address of 001'.Now I know how to update all the columns to say 'address of' which I think is:UPDATE customerSET address = 'address of' but how do I get the userId for each entry on to the end? Is it even possible?It would end up looking something like thisaddress of 001address of 002address of 003etc...Instead of the actual addresses.Could it be as simple as this:UPDATE customerSET address = 'address of' + userId or something to that effect, sorry my syntax is probably a bit off. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-07-27 : 14:33:09
|
| Yes that's how it would be done. However, if the userId column is integer, you'll need to convert it to varchar. You've probably got varchar anyway though as integer wouldn't give you the leading two zeroes.UPDATE customerSET address = 'address of ' + CONVERT(varchar(10), userId)Tara |
 |
|
|
callmejabba
Starting Member
4 Posts |
Posted - 2005-07-27 : 14:47:18
|
| Thanks a lot! |
 |
|
|
|
|
|