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 |
|
alexjamesbrown
Starting Member
48 Posts |
Posted - 2009-01-13 : 05:05:35
|
Hi, Currently, we have a users table with a schema like:UserID | UserName1 | joebloggs2 | jonsmith3 | alexjamesbrownWe then have a table (we'll call this Profile for the sake of this..) with a schema like:User | HairColour | FavouriteFood1 | Brown | Pizza2 | Blonde | Pasta3 | Brown | ChineseWhat i need to do is replace the User column in the Profile table with the actual user name, stored in the users table something like...update Profile set User = (SELECT username from Users where UserID = ???) this would make the above profile table read:User | HairColour | FavouriteFoodjoebloggs | Brown | Pizzajonsmith | Blonde | Pastaalexjamesbrown | Brown | ChineseThanks for your help |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-13 : 05:18:05
|
| first alter ur user column in varchar if it is intthen try thisalter table profiles alter column users varchar(32)update profiles set users = u.usernamefrom users uwhere users = u.userid |
 |
|
|
alexjamesbrown
Starting Member
48 Posts |
Posted - 2009-01-13 : 07:41:48
|
| perfect, worked brilliantly.cheers. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-13 : 07:44:53
|
quote: Originally posted by alexjamesbrown perfect, worked brilliantly.cheers.
welcome |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-13 : 08:44:58
|
| why should you do this? isnt it enough to join onto users table and get this information directly in select statements while retrieving the value? |
 |
|
|
|
|
|