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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-09-21 : 07:19:39
|
| Yoni writes "Hi AllPlease provide SQL query syntax for the following: Copy TableA.Usernames from TableA to TableB for all records where TableA.LastName = TableB.LastNameThank you.Yoni" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-09-21 : 07:21:45
|
INSERT INTO TableBSELECT A.*FROM TableA A INNER JOIN TableB B ON A.LastName=B.LastNameDon't know why you want to copy rows that already exist in the table, but that should do it.Hope you get a good score on the test. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-21 : 07:22:14
|
| Try thisUpdate T2 set T2.UserName=T1.UserName from TableA T1 inner join TableB T2 on T1.LastName = T2.LastNameMadhivananFailing to plan is Planning to fail |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-09-21 : 08:01:06
|
Wow, did I misread that question. Never mind, pretend I wasn't here. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-21 : 08:11:21
|
May be you are busy with thinking something else MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|