SSIS Fetch first latest record only

jn93 671 Reputation points
2022-12-22T08:07:24.09+00:00

Hi, I have one SSIS package which get data from txt file and to the destination sql table. Here below diagram shows the SSIS diagram to fetch the latest record based on VEHNO. Hence, I need to use aggregate function on max reqtimestamp group by VEHNO. However, when I have latest reqtimestamp with the same duplicate rows, it insert duplicate rows. How can I modify my SSIS package below to fetch first record only?

SSIS diagram:
273139-image.png

Desired Output:
273217-image.png

SQL Server Integration Services
0 comments No comments
{count} votes

Answer accepted by question author
  1. ZoeHui-MSFT 41,541 Reputation points
    2022-12-22T09:01:42.847+00:00

    Hi @jn93 ,

    You may use Sort Transformation to delete the duplicate value first.

    And then use Aggregate to get the max value(latest timestamp), note that the maximum value returns the maximum value in a group. For more information, see MAX (Transact-SQL). In contrast to the Transact-SQL MAX function, this operation can be used only with numeric, date, and time data types.

    aggregate-transformation

    273225-untitled.png

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.