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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update records

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 customer
SET 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 this

address of 001
address of 002
address of 003
etc...
Instead of the actual addresses.

Could it be as simple as this:

UPDATE customer
SET 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 customer
SET address = 'address of ' + CONVERT(varchar(10), userId)


Tara
Go to Top of Page

callmejabba
Starting Member

4 Posts

Posted - 2005-07-27 : 14:47:18
Thanks a lot!
Go to Top of Page
   

- Advertisement -