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 |
|
tech
Starting Member
32 Posts |
Posted - 2012-05-24 : 22:58:19
|
| So I have an existing table of "user" data.now a new field has been added: username.username is now compulsary but you cannot just add the column and make it "NOT NULL".so how can I (after alter table) update each row with a value for this new field by obtaining the value from the field "firstname" and 2 characters from the field "surname" and then finally from this concatination, update that row for the new field "username"?i.e:Firstname: steveLastname: tibbsbecomes:username: stevetithanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-25 : 01:40:58
|
[code]update yourtableset username = firstname + isnull(left(lastname, 2), '')[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|