3

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?

0

1 Answer 1

9
SELECT SERVERPROPERTY ('edition') 

Can also check it, when its not SQL Azure you know its on prem.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.