x
login about faq Site discussion (meta-askssc)

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 '09 at 06:05 PM in Default

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

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

2 answers: sort voted first

You could try

SELECT @@VERSION

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

James

more ▼

answered Oct 25 '09 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 '09 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 '09 at 08:42 PM

Rob Farley gravatar image

Rob Farley
5.7k 13 17 19

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 '09 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 '09 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

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x19

asked: Oct 24 '09 at 06:05 PM

Seen: 654 times

Last Updated: Oct 24 '09 at 06:05 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.