I want to only have 1 row in my table. I am populating a row from Server1 to Server2 on a single table using SSSIS. I am updating Execution End time that I get from a table in server1 to a table in server2. Here is the query I use to populate :
SELECT TOP 1 EXEC_END_TIME
FROM cr_stat_execution cse
WHERE cse.EXEC_NAME = 'ETL'
ORDER BY exec_end_time DESC
The problem: I only want to update server2's table with the recent record only or rewrite previous days data. I don't want to have a history on my table, how can I modify my query to only populate the most recent data from Server1 to Server2 without having rows of history.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
CREATE INDEX cr_execution_idx_exec_name_exec_time ON cr_stat_execution (EXEC_NAME,exec_end_time);
SELECT
TOP 1 cse.EXEC_END_TIME
FROM
cr_stat_execution cse
WHERE
cse.EXEC_NAME = 'ETL'
ORDER BY
cse.exec_end_time DESC