Sunday, August 30, 2009

How to use SQL Azure

Well,
If you want to play with SQL Azure it is little tricky. You cannot use SQL Server management Studio. However you can connect using ADO.NET. One option is to develop small app that does basic things like listing tables, enables editing tables etc, which actually is not that hard - to cover basic functionality.
Until then, the smoothest way I found is usign the SQLCmd tool.
Better described here: http://english.zachskylesowens.net/2009/08/18/connecting-to-sql-azure/
However this is the "quick-start":
sqlcmd -S MY_SERVER_NAME.ctp.database.windows.net -U MY_USERNAME@MY_SERVER_NAME -d DATABASE_NAME

The key here is that you must use MY_USERNAME@MY_SERVER_NAME !
For example, if your server name is h38ssfjeiwh201, your username is admin and connecting to sample_db your connection would be.
sqlcmd -S h38ssfjeiwh201.ctp.database.windows.net -U admin@h38ssfjeiwh201 -d sample_db

Also good point is that you must explicitly specify DataBase name to use, since AzureSQL CTP still does not support USE DataBaseName command.

Good luck and happy times with Sql Azure!

No comments: