T-SQL筆記18_SQL_sqlcmd 指令
指令:
sqlcmd -?
指令用法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | sqlcmd -a packet_size -A (dedicated administrator connection) -b (terminate batch job if there is an error) -c batch_terminator -C (trust the server certificate) -d db_name -D -e (echo input) -E (use trusted connection) -f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage] -g (enable column encryption) -G (use Azure Active Directory for authentication) -h rows_per_header -H workstation_name -i input_file -I (enable quoted identifiers) -j (Print raw error messages) -k[1 | 2] (remove or replace control characters) -K application_intent -l login_timeout -L[c] (list servers, optional clean output) -m error_level -M multisubnet_failover -N (encrypt connection) -o output_file -p[1] (print statistics, optional colon format) -P password -q "cmdline query" -Q "cmdline query" (and exit) -r[0 | 1] (msgs to stderr) -R (use client regional settings) -s col_separator -S [protocol:]server[instance_name][,port] -t query_timeout -u (unicode output file) -U login_id -v var = "value" -V error_severity_level -w column_width -W (remove trailing spaces) -x (disable variable substitution) -X[1] (disable commands, startup script, environment variables, optional exit) -y variable_length_type_display_width -Y fixed_length_type_display_width -z new_password -Z new_password (and exit) -? (usage) |
常用的方式
SQLCMD -S {DB Server Host} -U {login_id} -P {Password}
例如:
SQLCMD -S DESKTOP-REOVRN8\SQLEXPRESS -U sa -P 123###456
use {Database名稱}
Go
Ref:
SQL - 使用 SQLCMD
sqlcmd 公用程式
sqlcmd - 執行 Transact-SQL 指令碼檔案
https://dotblogs.com.tw/dc690216/2011/01/26/21068
留言
張貼留言