My query:
(SELECT (...abbreviated...), r.CardInformation, SYSDATETIME(), NULL ,''
FROM {1} r
LEFT OUTER JOIN [{2}] p ON r.ProcessDate = p.ProcessDateTime AND r.ProcessType = p.ProcessType AND r.SalesAmount = p.SalesAmount AND r.TerminalID = p.TerminalID AND r.SlipNumber = p.SlipNumber
WHERE r.ProcessDate >= '{3}' AND r.ProcessDate < '{4}' AND r.ProcessType >= '1' AND r.ProcessType <= '3' AND r.ErrorType = '0' AND r.ErrorCode = ' ' AND r.ProcessResult <> '0' AND r.ProcessResult <> ' ' AND r.ReversalType = '0'
UNION
SELECT (...abbreviated...), r.CardInformation, SYSDATETIME(),NULL ,''
FROM {1} r
LEFT OUTER JOIN [{2}] p ON r.ProcessDate = p.ProcessDateTime AND r.ProcessType = p.ProcessType AND r.SalesAmount = p.SalesAmount AND r.TerminalID = p.TerminalID AND r.SlipNumber = p.SlipNumber
WHERE r.SalesFixDate = '{3}' AND r.ProcessDate < '{4}' AND r.ProcessType >= '1' AND r.ProcessType <= '3' AND r.ErrorType = '0' AND r.ErrorCode = ' ' AND r.ProcessResult <> '0' AND r.ProcessResult <> ' ' AND r.ReversalType = '0' )
I would like to know the execution order of the above statement. Specifically, I want to know what situations (if any) where the call to sysdatetime()
in both select statements will be different.
In one of our production servers, the above statement for some reason on a particular day/time caused a time gap of .003 seconds between the two calls of sysdatetime()
. Is this expected behavior? As it is one query sent to the SQL Server, wouldn't the two calls to sysdatetime()
produce the same results? Any thoughts on this is appreciated.