Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Merging two one to one tables

Posted on 2013-06-30
1
Medium Priority
?
270 Views
Last Modified: 2013-06-30
I have two tables with a one to one relationship.


As an example:

ClientTable
clientId
startdate
firstname
lastname

ClientInfoTable
ClientInfoId
ClientId
address1
address2
city
state
zip
phone


I want to add the fields from the second table into the first table. I can add the empty fields. But I need to know, once I've added the fields, is there a way to run a query that will import that data from table2 into table1's fields? Then I can delete table2.

I know I can do this with a loop one row at a time, but I'm wondering if there is some kind of update query that will do them all at once with the query?

thanks!
0
Comment
Question by:Starr Duskk
1 Comment
 
LVL 2

Accepted Solution

by:
Starr Duskk earned 0 total points
ID: 39288544
I figured it out, something like this, but with all the fields needed.

MERGE Client AS cli
 USING (SELECT clientid,WorkPhone FROM clientInformation) AS ci
ON cli.clientid = ci.clientid
 WHEN MATCHED THEN UPDATE SET cli.WorkPhone = ci.WorkPhone
 ;

thanks!
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question