Databases Reference
In-Depth Information
■
SQL Database 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.
Note
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 Database instance. 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:
At the command prompt, use the sqlcmd syntax and type in your connection information, as shown in Figure
5-3
.
(In the figure, the server name and password are hidden.) Press Enter.
Figure 5-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
5-4
, the following
SELECT
statement is entered and executed:
SELECT FirstName, LastName FROM Person.Person