Sunday 23 August 2009

Connecting to SQL Azure Database with a management tool

Whilst working on my new book Azure in Action (first 3 chapters are available now online), I thought I’d write up how to connect to SQL Azure Database using a database browser tool.

If you are lucky enough to have received your SQL Azure Database invitation token you will have noticed that you cannot connect SQL Server Management Studio to your cloud database.

However this is not to say that you cannot use another tool to perform the same job.

Universal SQL Editor

The Tool I have used is Universal SQL Editor which has a 14 day trial and is a reasonable cost at $39 beyond that.  It’s a pretty good tool actually (please note I’m not affiliated with them in any way), it has intellisense and can talk to loads of different db types.

Setting up a DSN Connection

In the SQL Azure Portal I already created a database called “HawaiianShirts” which I will now connect to using the tool.  To do that I created a file DSN which points to my DB.  I called the DSN file “HawaiianShirts.dsn” and the contents of the DSN are below:

[ODBC]
DRIVER=SQL Server Native Client 10.0
UID=<myusername>@<myservername>
WSID=<mypcname>
APP=2007 Microsoft Office system
SERVER=<myservername>.ctp.database.windows.net
DATABASE=HawaiianShirts

So for example (not real data)

[ODBC]
DRIVER=SQL Server Native Client 10.0
UID=chris@a123456
WSID=CHRIS-PC
APP=2007 Microsoft Office system
SERVER=a123456.ctp.database.windows.net
DATABASE=HawaiianShirts

I can now use this file DSN to open a connection to the database.  I can use this editor to both create tables, stored procedures and view/edit data.

Here is a screenshot of me using the tool to edit some data in a table in SQL Azure Database

image

No comments: