The following table provides an overview of commands that you can use from within the sqlcmd utility. For more information about these commands, see sqlcmd Utility in SQL Server 2008 Books Online.

Command

Description

go [count]

Executes any cached Transact-SQL statements. When specifying a value for count, the cached statements will be executed count times as a single batch. For example, the following example will execute the two statements twice:

This switch is used by the client to request an encrypted connection. This option is equivalent to the ADO.net option ENCRYPT = true.

-Ctrust the server certificate

This switch is used by the client to configure it to implicitly trust the server certificate without validation. This option is equivalent to the ADO.net option TRUSTSERVERCERTIFICATE = true.

reset

Clears the statement cache.

ed

Lets you edit the current or last executed statement batch. To edit the last executed batch, this command must be typed immediately after the last batch has executed.

!! <command>

Executes operating system commands. To execute an operating system command, start a line with two exclamation marks (!!) followed by the operating system command. For example, the following performs a directory listing of the current drive:

When you connect to a SQL Server Express server, you must specify the server name and, if SQL Server Express is installed in a named instance, the instance name. By default, sqlcmd uses Windows Authentication. If you are connecting to the SQL Server Express server by using SQL Server Authentication, you must also provide the logon information for connecting to the SQL Server Express server. For example, if you are connecting to a default installation of SQL Server Express on a server named server1, you might use the following arguments:

Example

After you are connected, you can issue other commands to manage the instance. For example, the following commands will display all currently installed databases. This is a convenient way to find the logical name of an attached SQL Server Express database:

You can manage and optimize SQL Server Express resources through configuration options by using the sp_configure system stored procedure. For more information about sp_configure, see Setting Server Configuration Options in SQL Server Books Online.

The following configuration options are part of sp_configure, but are not supported in SQL Server Express: