Solved

Update  Data from One  Table to Another

Posted on 2014-09-17
3
107 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank You,
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now