Suppose I have a piece of T-SQL that gets variously run both on Azure SQL Database and on-premise SQL Server. How can I programmatically detect, within the script itself, which of these is the prevailing context?
I note that
SELECT @@VERSION
on Azure SQL Database yields a string that starts
Microsoft SQL Azure
but parsing the output of @@VERSION doesn't make for a nice feeling, and of course the specifics could change at any time.
Is there a more-obviously-correct way of doing this?