Solved

Update  Data from One  Table to Another

Posted on 2014-09-17
3
111 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

813 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

14 Experts available now in Live!

Get 1:1 Help Now