Database Reference
In-Depth Information
This section discusses how to use the sqlcmd utility to connect to a SQL Azure database and execute
queries against that database. This section assumes that you have some familiarity with sqlcmd. This
utility has many options, or parameters, but this section only discusses those necessary to connect to
SQL Azure.
Note SQL Azure doesn't support the -z or -Z option for changing user passwords. You need to use ALTER
LOGIN after connecting to the master database in order to change a password.
To use the sqlcmd utility, you first open a command prompt. At the command prompt, you need to
provide the options and values necessary to connect to the SQL Azure database. As a minimum, the
command syntax is the following:
sqlcmd -U login -P password -S server -d database
The parameters are nearly self-explanatory, but here they are, just in case:
-U is the user login ID.
-P is the user-specified password. Passwords are case sensitive.
-S specifies the instance of SQL Server to which to connect.
Optionally, you can provide a database name via the -d parameter. Thus, the sqlcmd syntax looks
something like the following:
Sqlcmd -U providerlogin@Server -P ProviderPassword -S ProviderServer -d database
Let's put this syntax to use. Follow these steps:
1.
At the command prompt, use the sqlcmd syntax and type in your connection
information, as shown in Figure 6-3. (In the figure, the server name and password are
hidden.) Press Enter.
Figure 6-3. Connecting via sqlcmd
When the sqlcmd utility connects, you're presented with the sqlcmd prompt 1> , at
which point you can begin typing in and executing T-SQL commands. The
command to execute any T-SQL statement is GO . For example, in Figure 6-4, the
following SELECT statement is entered and executed:
SELECT Name FROM Users
2.
Search WWH ::




Custom Search