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 |
eugz
Posting Yak Master
210 Posts |
Posted - 2015-02-26 : 16:34:29
|
Hi All.I need update Table2 for field usernamme using Table1 like source.The Table1 has field Name such as Smith, John.The Table2 has fields LastName and FirstName.How to update Table2?Thanks. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-02-26 : 16:36:23
|
Show us sample data and expected update data.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2015-02-26 : 17:51:25
|
Table1Name...........................Phone..................Username===============================================SMITH, JOHN.............2223334444..............smithj___________________________________________________________Table2LastName..............FirstName............Username===============================================SMITH..................JOHN Thanks |
|
|
pradeepbliss
Starting Member
28 Posts |
Posted - 2015-03-02 : 05:11:33
|
Update [Table2] set username = (Select T1.username from [Table1] T1 where Replace(replace(T1.name,',',''),' ','') = ltrim(rtrim(Table2.lastname))+ltrim(rtrim(Table2.firstname))) |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2015-03-02 : 10:17:43
|
Hi pradeepbliss. Thanks for replay.I need update field username of table2 by data username of table1. But you approach create username on base lastname and firstname of table1.How to update username of table2 by data username of table1?Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2015-03-02 : 13:26:26
|
How do you "connect" the two tables to eachother? Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2015-03-02 : 16:08:32
|
Hi pradeepbliss. Thanks for replay.I need update field username of table2 by data username of table1. But you approach create username on base lastname and firstname of table1.How to update username of table2 by data username of table1?Thanks. |
|
|
|
|
|
|
|