Solved

Update  Data from One  Table to Another

Posted on 2014-09-17
3
110 Views
Last Modified: 2014-09-18
I have two tables.  They have identical records,  They both have a batch and and AuthorizationNumber that match.  I need to get the below data from CallLogImport into CallLog where the Authorization and Batch match.  How can I structure the UPDATE TSQL to get the CallLogImport into the CallLog ?

SELECT    
    CallLogImport.AuthorizationNumber,
    CallLogImport.Batch,
    CallLogImport.EntryDate,
    CallLogImport.TelephoneAdvice,
    CallLogImport.StandardFee,
    CallLogImport.LTDCoverage,
    CallLogImport.OfficeConsult,
    CallLogImport.TelephoneOfficeFull
 FROM
    dbo.CallLogImport
WHERE
    Batch =300
   
   
SELECT
    CallLog.AuthorizationNumber,
    CallLog.Batch,
    CallLog.EntryDate,
    CallLog.TelephoneAdvice,
    CallLog.StandardFee,
    CallLog.LTDCoverage,
    CallLog.OfficeConsult,
    CallLog.TelephoneOfficeFull
FROM
    CallLog
WHERE
     Batch =300
0
Comment
Question by:charlesbaldo
3 Comments
 
LVL 2

Accepted Solution

by:
Akilandeshwari N earned 450 total points
ID: 40329537
If I understand correctly, you wold like to update the information from CallLogimport to CallLog for the Authorization and Batch matching records.
CREATE PROCEDURE dbo.SP_UPD
AS
BEGIN
	UPDATE    
	   CallLog
	SET
		EntryDate			=	CallImprt.EntryDate,
		TelephoneAdvice		=	CallImprt.TelephoneAdvice,
		StandardFee			=	CallImprt.StandardFee,
		LTDCoverage			=	CallImprt.LTDCoverage,
		OfficeConsult		=	CallImprt.OfficeConsult,
		TelephoneOfficeFull	=	CallImprt.TelephoneOfficeFull
	FROM
		CallLog			log,
		CallLogImport	CallImprt
	WHERE
		log.AuthorizationNumber = CallImprt.AuthorizationNumber
	AND log.Batch = CallImprt.Batch
END
GO

Open in new window

0
 
LVL 4

Assisted Solution

by:jindalankush
jindalankush earned 50 total points
ID: 40329664
SELECT    
     cli.AuthorizationNumber,
     cli.Batch,
     cli.EntryDate,
     cli.TelephoneAdvice,
     cli.StandardFee,
     cli.LTDCoverage,
     cli.OfficeConsult,
     cli.TelephoneOfficeFull
 FROM
    dbo.CallLogImport cli WITH (NOLOCK)
                  inner join
            CallLog cl  WITH (NOLOCK)
                  ON      
                  cli.Batch      =cl.Batch
                        AND
                  CLI.AuthorizationNumber            = CL.AuthorizationNumber
0
 

Author Closing Comment

by:charlesbaldo
ID: 40330319
Thank You,
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

910 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

23 Experts available now in Live!

Get 1:1 Help Now