Execute Dynamic SQL with sp_executesql
Sources: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-executesql-transact-sql?view=sql-server-ver15
Sources: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-executesql-transact-sql?view=sql-server-ver15
For multiple date type options… and one set of date range field. 1 for Transaction Date 2 for Business Date 3 for Posted Date
Sources:
Converts an inputdate to the corresponding datetimeoffset value in the target time zone. When inputdate is provided without offset information, the function applies the offset of the time zone assuming that inputdate is in the target time zone. If inputdate is provided as a datetimeoffset value, then AT TIME ZONE clause converts it into the target time zone using the time zone conversion rules. AT TIME ZONE implementation relies on... » read more
UNION The UNION command combines the result set of two or more SELECT statements (only distinct values). UNION ALL The UNION ALL command combines the result set of two or more SELECT statements (allows duplicate values).
Look for duplicate records. Remove duplicate records