Solved

Merging two one to one tables

Posted on 2013-06-30
1
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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