Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

how to pick the latest record from a table and insert into another table

$
0
0
I have a scenario where I have to create a replication of a target table along with source Id field.If I have Target Table with columns :Target_ID,name,createdate which is getdate()Then my target replication table will be: Target_ID, name, createdate which is getdate(),source_IDOnce the record hits the target table , I want the record to be inserted into replication table along with source Id. I can do this and it is working. but I would like to include the condition that only if record is inserted in target then insert in replication table else do not do anything.As of now I am picking up the latest record from target and inserting into replication table. What if there is no record inserted , even then my code would pick the latest record and insert into replication table. Any help is appreciated!

Viewing all articles
Browse latest Browse all 3145

Trending Articles