'Share code stored procedure in SQL Server

I have created a destination data table (exp: tbl_des_txn) with the same structure as the source data table (exp: tbl_source_txn). including columns: txn_id, txn_description, txn_date.

I need to write procedure to get daily data from tbl_source_txn to tbl_des_txn. where set condition is etl status of source data table = ready (this status is stored in tbl_ready_status table). Including columns: table_name, etl_status, business_date, etl_startTime, etl_endTime In fact, the etl_endTime is not fixed (today maybe at 3:00 pm but tomorrow maybe at 4:00 pm) if I create auto schedule for this job at 3pm is there any problem if tbl_source_txn is ready after 4pm I'm just a beginner, so I'm looking forward to your advice.

My procedure as bellows:

CREATE PROCEDURE InsertTXNNewRecords
as
begin
    insert into tbl_des_txn
    values (select a.txn_id, 
                   a.txn_description, 
                   a.txn_date
            from tbl_source_txn  a, tbl_ready_status b
            where b.table_name = 'tbl_source_txn' and b.ETL_Status = 'ready' and b.business_date = CURRENT_DATE())
end


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source