?
Solved

Update  Data from One  Table to Another

Posted on 2014-09-17
3
Medium Priority
?
116 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 1800 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 200 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.
Suggested Courses

752 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