SQL Azure Connection Type (SSRS)

Microsoft SQL Azure Database is a cloud-based, hosted relational database built on SQL Server technologies. To include data from SQL Azure Database in your report, you must have a dataset that is based on a report data source of type SQL Azure. This built-in data source type is based on the SQL Azure data extension. Use this data source type to connect to and retrieve data from SQL Azure Database.

SQL Azure is similar to an instance of SQL Server on your premises and getting data from SQL Azure Database is, with a few exceptions, identical to getting data from SQL Server. SQL Azure Database features align with SQL Server 2008.

For more information about SQL Azure, see "SQL Azure" on msdn.microsoft.com.

When you connect to SQL Azure, you are connecting to a database object in the cloud. Just like onsite databases, the hosted database might have multiple schemas that have multiple tables, views, and stored procedures. You specify the database object to use in the query designer. If you do not specify a database in the connection string, you connect to the default database that the administrator assigned to you.

Contact your database administrator for connection information and for the credentials to use to connect to the data source. The following connection string example specifies a hosted sample database named AdventureWorks.

In addition, you use the Data Sources Properties dialog box to provide credentials such as user name and password. The User Id and Password options are automatically appended to the connection string; you do not need to type them as part of the connection string.

Windows Authentication (integrated security) is not supported. If you attempt to connect to SQL Azure using Windows Authentication an error occurs. SQL Azure supports only SQL Server Authentication (user name and password) and users must provide credentials (login and password) every time they connect to SQL Azure.

Credentials must be sufficient to access the database. Depending on your query, you might need other permissions, such as sufficient permissions to run stored procedures and access tables and views. The owner of the external data source must configure credentials that are sufficient to provide read-only access to the database objects that you need.

From a report authoring client, the following options are available to specify credentials:

Use a stored user name and password. To negotiate the double hop that occurs when the database that contains the report data is different than the report server, select options to use credentials as Windows credentials. You can also chose to impersonate the authenticated user after connecting to the data source.

A query specifies which data to retrieve for a report dataset. The columns in the result set for a query populate the field collection for a dataset. If the query returns multiple result sets, the report processes only the first result set that the query retrieves. Although there are some differences between SQL Server and SQL Azure databases such as the sizes of databases supported, writing queries against SQL Azure databases is similar to writing queries against SQL Server databases. Some Transact-SQL statements such as BACKUP are not supported in SQL Azure, but they are not ones that you use in report queries. For more information, see SQL Server Connection Type (SSRS).

By default, if you create a new query or open an existing query that can be represented in the graphical query designer, the relational query designer is available. You can specify a query in the following ways:

Build a query interactively. Use the relational query designer that displays a hierarchical view of tables, views, stored procedures, and other database items, organized by database schema. Select columns from tables or views, or specify stored procedures or table-valued functions. Limit the number of rows of data to retrieve by specifying filter criteria. Customize the filter when the report runs by setting the parameter option.

Type or paste a query. Use the text-based query designer to enter Transact-SQL text directly, to paste query text from another source, to enter complex queries that cannot be built by using the relational query designer, or to enter query-based expressions.

Import an existing query from a file or report. Use the Import query button from either query designer to browse to a .sql file or .rdl file and import a query.

Depending on the complexity of a query and the data that the query returns, the query might take a long time to complete. In this release of SQL Azure, idle connections and long running queries or transactions are closed after five minutes. Queries that require more than five minutes to complete will fail. It is recommended that you design report queries to be as efficient as possible when getting report data from SQL Azure.

The graphical query designer that SQL Azure uses provides built-in support for grouping and aggregates to help you write queries that retrieve only summary data. The Transact-SQL language features are: the GROUP BY clause, DISTINCT keyword, and aggregates such as SUM and COUNT. The text-based query designer provides full support for the Transact-SQL language, including grouping and aggregates. For more information about Transact-SQL, see Transact-SQL Reference (Database Engine)in SQL Server Books Online on msdn.microsoft.com.

Using Query Type Text

In the text-based query designer, you type Transact-SQL commands to define the data in a dataset. For example, the following Transact-SQL query selects the names of all employees who are marketing assistants:

Using Query Type StoredProcedure

You can specify a stored procedure for a dataset query in one of the following ways:

In the Dataset Properties dialog box, set the Stored Procedure option. Choose from the drop-down list of stored procedures and table-valued functions.

In the relational query designer, in the Database view pane, select a stored procedure or table-valued function.

In the text-based query designer, select StoredProcedure from the toolbar.

After you select a stored procedure or table-valued function, you can run the query. You will be prompted for input parameter values. When you run the query, report parameters that correspond to input parameters are automatically created. For more information, see Query Parameters later in this topic.

Only the first result set that is retrieved for a stored procedure is supported. If a stored procedure returns multiple result sets, only the first one is used.

If a stored procedure has a parameter that has a default value, you can access that value by using the DEFAULT keyword as a value for the parameter. If the query parameter is linked to a report parameter, the user can type or select the word DEFAULT in the input box for the report parameter.

For more information about stored procedures, see "Stored Procedures (Database Engine)" in SQL Server Books Online on msdn.microsoft.com.

When query text contains query variables or stored procedures that have input parameters, the corresponding query parameters for the dataset and report parameters for the report are automatically generated. The query text must not include the DECLARE statement for each query variable.

For example, the following SQL query creates a report parameter named EmpID:

By default, each report parameter has data type Text and an automatically created dataset to provide a drop-down list of available values. After the report parameters are created, you might have to change default values. For more information, see Parameters (Report Builder 3.0 and SSRS).

These sections of the documentation provide in-depth conceptual information about report data, and procedural information about how to define, customize, and use parts of a report that are related to data.