C H A P T E R 8 ■ ■ ■ 243 SQL Azure At the end of July 2009 Microsoft announced SQL Azure community technology preview (CTP) and aimed to go live in November 2009 for SQL Azure and to phase out SQL Data Services (SDS). SQL Azure and SDS are both cloud-based services but are built using different data models. With the introduction of SQL Azure, Azure has reached a breakthrough point, leaving this new platform in a good position to be accepted by the enterprise and for winning marking share, since: • SQL Azure is the first cloud service completely supporting the relational database model. • SQL Azure is fully committed to supporting T-SQL, SQL query, stored procedures, data views, and so on. • SQL Azure supports the traditional Windows user/password security model. • The first release of SQL Azure is almost fully compatible with all existing relational development tools and IDEs, such as SQL Server Management Studio (SSMS) and Visual Studio. • SQL Azure allows all SQL developers and IT staff to seamlessly migrate from an on- premises environment to a cloud environment with almost no learning curve. All knowledge and skills for SQL developers and IT staff can be applied to SQL Azure. This should remove a big concern from when the Azure framework was announced in October 2008 regarding potential job losses for the IT industry (worries brought on because the infrastructure and data storage hardware for an organization no longer need to exist in the organization). • SQL Azure supports PHP, which makes SQL Azure more friendly to Internet applications. The most important thing is that SQL Azure is the first platform supporting the rational database model and database as a service running in the cloud. The major changes are not in the physical domain but in the logical virtual domain. Since SQL Server and T-SQL have been in the market for decades, there is a lot of information that can be found on them. This chapter does not cover SQL or T-SQL based upon the assumption that you know SQL. Instead, this chapter covers the fundamentals, including how to register to set up your SQL Azure account and how to connect to a cloud database from SSMS. CHAPTER 8 ■ SQL AZURE 244 Create a Virtual Server for SQL Azure The first step to using SQL Azure is to create a SQL service. For a CTP account user, redeem your invitation code from Microsoft and create a SQL service. You will see the results when a SQL service has been created in the cloud as Figure 8-1 shows. Figure 8-1. The results of creating a SQL Azure server from the cloud Click the Manage link, and you will be redirected to the management page where you can see that a default database, master, has been created in the SQL Azure server you have just created. Click the Connection Strings button, and you get the connection strings for ADO.NET, ODBC, and OLE DB as shown in Figure 8-2. You can use them to access this database using SQL access clients. You will also be able to see that the server name is assigned to the SQL Azure server that you have just created. CHAPTER 8 ■ SQL AZURE 245 Figure 8-2. The connection strings used to access SQL Azure using ADO.NET, ODBC, or OLE DB You can easily create a new database by clicking the Create Database button in the management page. An example of the results of creating a custom database is shown in Figure 8-3. Figure 8-3. Create a custom SQL Azure database SQLAzureIntroduction Connect to a SQL Azure Database Using SQL Server Management Studio Please bear in mind that SQL Azure does not support object browsing from SQL Server Management Studio. To connect to the SQL Azure database in the cloud using SQL Server Management Studio, launch SQL Server Management Studio. Close the Connect to Server dialog box and click the ribbon button New Query as Figure 8-4 shows. This will lead you back to the Connect to Server dialog box again. By clicking the Options button and selecting the Connection Properties tab, you can specify the target custom CHAPTER 8 ■ SQL AZURE 246 database you created in the cloud. The correct server name must be filled in as Figure 8-4 shows. The format of the server name is: [Data server name assigned by SQL Azure].ctp.database.windows.net The authentication type that should be selected is SQL Server Authentication. The login name and password are the same as the ones you used to redeem your invitation code. After the connection succeeds you may get an error message box as Figure 8-5 shows. This is a known issue in the current SQL Azure release, but it will not prevent you moving forward. Figure 8-4. To connect to SQL Azure database, click the ribbon button New Query CHAPTER 8 ■ SQL AZURE 247 Figure 8-5. A known issue in the current SQL Azure release when connecting to the SQL Azure database using SQL Server Management Studio A quick way to verify the creation of the database from the cloud is to execute the following T-SQL query: SELECT * FROM sys.databases The returned message should show that the database exists in the current virtual SQL Azure server as Figure 8-6 shows. Figure 8-6. Using SELECT * FROM sys.databases to query information of existing databases from the virtual data server SQL Azure Timeout The connection to SQL Azure will be automatically deactivated if there is no activity detected by SQL Azure. The error message will be thrown as below, and you just need to reconnect to the service by clicking on the button shown in Figure 8-7 from SQL Server Management Studio. Msg 10053, Level 20, State 0, Line 0 A transport-level error has occurred when sending the request to the server. (provider: . T-SQL, SQL query, stored procedures, data views, and so on. • SQL Azure supports the traditional Windows user/password security model. • The first release of SQL Azure is almost fully compatible. shows. The format of the server name is: [Data server name assigned by SQL Azure].ctp.database .windows. net The authentication type that should be selected is SQL Server Authentication. The