Personal use sqlcmd command:
SQLCMD-E-I test.sql-d databasename-s 127.0.0.1
The sqlcmd command explains:
Usage: Sqlcmd [-u login ID] [-p password]
[-s server] [-H host name] [-E Trusted Connection]
[-D using Database name] [-L login Timeout value] [-t query timeout value]
[-H title] [-S column delimiter] [-w Screen width]
[-A packet size] [-e echo input] [-I allow quoted identifiers]
[-C command end] [-L[C] list servers [clear output]]
[-Q "Command-line query"] [-Q ' command-line query ' and exit]
[-m error level] [-V Severity level] [-W Delete trailing spaces]
[-u Unicode Output] [-R[0|1] message sent to stderr]
[-I input file] [-O Output FILE] [-Z New Password]
[F < code page > | i:< code page >[,o:< code page;]] [-Z New Password and exit]
[-k[1|2] Delete [replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] Print statistics [colon format]]
[-R using client locale]
[-B Abort batch On ERROR]
[-V variable = "value" ...] [-A dedicated management connection]
[-x[1] Disable command, startup script, environment variable [and exit]]
[-X disables variable condition]
[-? display syntax summary]
The following links can be found in the detailed usage:
http://blog.csdn.net/leamonjxl/article/details/6428753
SQL SQL Server Execution File command (sqlcmd)