Azure Compatibility

Seeder question: I have been asked by one of my clients to make my client application SQL Azure compatible. While I have tested and there are only a few tweaks to make, I now need to make sure that my client application can reliably determine when it is connected to SQL Azure. How might I do that?

more ▼

asked Oct 24, 2009 at 06:05 PM in Default

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

You could try


Not sure what that returns on SQL Azure but you might be able to differentate using it.


more ▼

answered Oct 25, 2009 at 11:38 AM

James Moore gravatar image

James Moore
178 2 2 3

I'm going to accept this one, although what I'd have really like to have seen is something like SELECT CASE WHEN CHARINDEX('Azure', @@VERSION) > 0 THEN 1 ELSE 0 END as IsAzure
Oct 28, 2009 at 10:10 AM Matt Whitfield ♦♦
(comments are locked)
10|1200 characters needed characters left

SQL Azure has a few extra things in it, like a system view called sys.bandwidth_usage. Therefore, you could test for its existence. This will give you 0 if there is no such view, and 1 if there is:

SELECT SIGN(ISNULL(SUM(object_id),0)) AS IsAzure FROM sys.all_objects WHERE name = 'bandwidth_usage' AND schema_id = 4; 
more ▼

answered Oct 25, 2009 at 08:42 PM

Rob Farley gravatar image

Rob Farley
5.7k 16 18 20

Can you think of a way that would work on any SQL Server Version? My theoretical app needs to connect to any SQL Server version including 2000...
Oct 26, 2009 at 06:24 AM Matt Whitfield ♦♦
Well, otherwise you can check the server properties. I just don't know if there's one that indicates it's Azure.
Oct 26, 2009 at 07:07 AM Rob Farley
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 24, 2009 at 06:05 PM

Seen: 1137 times

Last Updated: Oct 24, 2009 at 06:05 PM