I'm trying to create a query that will merge only Trips occurring in the next 3 days. The Query will be ran on Microsoft flows nightly to populate company app. Db is running on Azure SQL and [Trip Date] data type is datetime2.
I have tried between getdate() and getdate() + 3
with no luck, all records merged. I appreciate any help.
merge TblAppTrips as target
using TblTrips as source on (target.TripID = source.TripID)
When matched then
update
set TripId = source.TripID,
cost = source.cost,
[Trip Date] = source.[Trip Date]
when not matched then
insert ([TripID], [cost], [Trip Date])
values (source.[TripID], source.[cost], source.[Trip Date]);