Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

get list of records from source table and update column

$
0
0

Hi

In my RequestLog table, i will get multiple request ids, with different executionid.

i want to update SAPSOURCE Table 'Requestid" column where requestid in ("Reqestlog-requestid") and ExecutionID <> ("Reqestlog-executionid")

DECLARE @varRequestId  NVARCHAR(255);
DECLARE @varExecutionId  NVARCHAR(255);


select    @varRequestId = RequestID , @varExecutionId =  _AuditCreatedExecutionId from STA.RequestLog where Source  =  'SAPSOURCE'  and cast(_AuditCreatedDate as date) = cast(getdate() as date)

UPDATE STA.SAPSOURCE set RequestID  = 0  where RequestID in (@varRequestId) and   _AuditCreatedExecutionID <>  @varExecutionId
the reason is there are records duplicated in the SAPSOURCE Table, where the _AuditCreatedExecutionId is not found in RequestLog Table.


ShanmugaRaj



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>