How do you get the default compatibility level in Azure SQL Database from T-SQL?
I couldn't find anything specifically documented for this, but:
SELECT SERVERPROPERTY('ResourceVersion');

...currently returns &quot;15.00.2000&quot; for Azure SQL Database, which may be useful to you.
I had thought you might be able to query:
SELECT H.[name]
FROM sys.dm_exec_valid_use_hints AS H 
WHERE H.name LIKE N'QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_%';

...but that returns:




name




QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_100


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_110


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_120


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_130


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_140


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_150


QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_160




...which are all valid hints, but 150 is the maximum you can set database compatibility to at the time of writing.