Using the sqlcmd utility, you can enter Transact-SQL statements, system procedures, and script files at the command prompt, in the Query Editor in SQLCMD mode, in the Windows script file, or in the operating system (Cmd.exe) job step of the SQL Server agent job 。 This utility uses OLE DB to perform Transact-SQL batch processing.
sqlcmd
[{-U login_id [-p password]} |–e trusted Connection}]
[-Z New Password] [-Z New Password and exit]
[-S server_name [\ instance_name]] [-H Wksta_name] [-D db_name]
[-L Login Time_out] [-A dedicated admin connection]
[-I. Input_file] [-O output_file]
[-F < codepage > | I: < codepage > [<, O: < codepage >]]
[-u Unicode Output] [-R [0 | 1] msgs to stderr]
[-R use client regional Settings]
[-Q "CmdLine query"] [-Q "CmdLine query" and exit]
[-e echo input] [-t query Time_out]
[-I enable Quoted Identifiers]
[-V var = "value" ...] [-x Disable variable substitution]
[-H headers] [-S Col_separator] [-W Column_width]
[-W Remove trailing spaces]
[-K [1 | 2] remove[replace] control characters]
[-y Display_width] [-y Display_width]
[-B On Error batch abort] [-V Severitylevel] [-M Error_level]
[-A packet_size] [-C Cmd_end]
[-l [C] list Servers[clean output]]
[-P [1] Print Statistics[colon format]]
[-X [1]] Disable commands, startup script, enviroment variables [and exit]
[-? show syntax summary]
Simple example:
Sqlcmd-u sa-p 1234567-s 192.168.1.1
Note Case,
Run SQL Server 2005 at the command prompt