Solved

Merging two one to one tables

Posted on 2013-06-30
1
259 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:BobCSD
1 Comment
 
LVL 1

Accepted Solution

by:
BobCSD 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now