How to get result from Update statement?

How to get result of Update statement in output statement
I work on sql server 2012

  update r set r.PartsLCUpdated=1,r.PartsLCDate=getdate(), r.IsValid=g.IsValid, r.HasReplacementCode=g.NewHasReplacementCode, r.JobUpdateHasreplacement=g.JobUpdateHasreplacement
	  	  output Inserted.PartsLCUpdated,Inserted.PartsLCDate,Inserted.IsValid,Inserted.HasReplacementCode,Inserted.JobUpdateHasreplacement into #getfinal
	     from replaceTest2 r with(nolock)
   inner join #GetDataElastic g on g.PartIDC=r.partidc and g.PartIDX=r.partidx and g.OldHasReplacementCode=r.HasReplacementCode and g.IsValid=r.IsValid

I need to get result of update statement on output
so How to do that please ?

1 Like

what have you done so far to resolve this? Have you looked at this? read it?

so How to get result of update by any way

You have been asking on this forum close to a year now @ahmedbarbary. I think by now you should be able to demonsttate that you have at least attempted to find a solution. People would love to help you, but we cant do your work either. What have you tried and what did not work?

thank you it solved
DECLARE @getfinal table( PartsLCUpdated int,
PartsLCDate datetime,
IsValid varchar(50),
HasReplacementCode varchar(50),
JobUpdateHasreplacement varchar(50));

 update r 
 set r.PartsLCUpdated=1,r.PartsLCDate=getdate(),r.IsValid=g.IsValid, r.HasReplacementCode=g.NewHasReplacementCode, r.JobUpdateHasreplacement=g.JobUpdateHasreplacement
 output 
 Inserted.PartsLCUpdated,Inserted.PartsLCDate,Inserted.IsValid,Inserted.HasReplacementCode,Inserted.JobUpdateHasreplacement 
 into @getfinal
 from replaceTest2 r with(nolock)
 inner join #GetDataElastic g on g.PartIDC=r.partidc and g.PartIDX=r.partidx and g.OldHasReplacementCode=r.HasReplacementCode and g.IsValid=r.IsValid
    
 Select * from @getfinal
1 Like