Mastering SQLCMD

In Exercises 4.1, 4.2, and 4.3, you were introduced to the SQLCMD utility. This command-prompt utility is used to interact with the SQL Server. SQLCMD supports dozens of switches as shown in Figure 4.9. Pay close attention to these switches as they are case-sensitive. For example, the -S switch specifies the server to which you want to connect, but the -s switch specifies the column separator for output. As another example, the -Q switch is used to run the specified query and exit, while the -q switch runs the query and remains in the SQLCMD interactive mode prompt.

FIGURE 4.19 SQLCMD switches

image

The simplest way to use SQLCMD is ...

Get SQL Server® 2008 Administration: Real World Skills for MCITP Certification and Beyond now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.