Skip to Content
0
Jul 25, 2020 at 04:08 PM

How to write a query which looks reports back the order status each day

58 Views

I have a requirement to write a query which will run on a scheduled basis late at night and for it to export out to a txt file.

Specifically - I need the query to look at all orders which have been updated during the day and provide an updated order status.

Right now I have this query in place:

Declare @Date1 Date Set @Date1 = GETDATE()

SET NOCOUNT ON

SELECT T0.[DocNum], convert(varchar(10), T0.[DocDate], 103) as 'Doc Date', T0.[CardCode], T0.[CardName], T0.[DocStatus] FROM ORDR T0

WHERE T0.[UpdateDate]=@date1

ORDER BY T0.[DocNum]

This query as I've discovered is flawed and the ORDR UpdateDate doesn't log anything when an order is converted into an invoice.

I need to somehow amend this query to include the order statuses for all orders affected in a given day.

Any help would be appreciated!

Cheers

Rick