Solved

Merging two one to one tables

Posted on 2013-06-30
1
267 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

734 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