In the latter, the last 5 digits are always repeating values. The value is less precise (or do I mean less accurate?) when the function runs on Azure SQL. Why is the behavior different?
The documentation for SYSDATETIMEOFFSET says:
SQL Server obtains the date and time values by using the GetSystemTimeAsFileTime() Windows API. The accuracy depends on the computer hardware and version of Windows on which the instance of SQL Server is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API.
But if the hardware matters, I don't expect I'll be able to know that information for Azure SQL.
I am working around this issue by instead using this sort of query to get a more precise datetimeoffset value:
SELECT (SYSUTCDATETIME() AT TIME ZONE 'UTC')
For some reason SYSUTCDATETIME doesn't suffer from the "last 5 digits repeat" issue when I run it on Azure SQL. The documentation for SYSUTCDATETIME does say:
SYSDATETIME and SYSUTCDATETIME have more fractional seconds precision than GETDATE and GETUTCDATE.
but it doesn't mention having more precision than SYSDATETIMEOFFSET.
Either fix SYSDATETIMEOFFSET on Azure SQL or expand the documentation so that developers can know what precision can be relied upon from SYSDATETIMEOFFSET and SYSUTCDATETIME on Azure SQL.