Solved

Update  Data from One  Table to Another

Posted on 2014-09-17
3
115 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:Charles Baldo
[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
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:Charles Baldo
ID: 40330319
Thank You,
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

690 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