Copy all colums from table a to table b

I have two tables

Client and Application

Both tables have the same columns ClientID,  Employer and Income

I want to update all the info from Application to Client based on the ClientID
Charles BaldoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
Your script will look something like this:

update c
set clientfieldnametoupdate = a.applicationfieldnametoupdate
from client as C
inner join application as A
on A.ClientID = C.ClientID

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dbaSQLCommented:
something simple like this --

update client
set Employer = b.Employer,
Income = b.Income
from Application b inner join Client
on client.clientID = b.ClientID
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Eric is correct as far as the literal interpretation of 'update', but just for kicks and giggles please provide more details on what you mean by this.

Do you wish to relate Client and Application, and for a given set of matches by primary key(s) change the values of Application to match those in Clients?  That would be an update.

Or ... do you wish to take all Client rows and move them into Application?  That would be an insert.   Or maybe delete all rows in Application, then move all rows from Client to Application.

Another consideration is do you wish to retain any history of old rows?
0
Charles BaldoSoftware DeveloperAuthor Commented:
Thank you all, I learned
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.