path: c:\program files\microsoft sql server\100\tools\binn\sqlcmd.exe
powershell examples
- execute command-line query, connect using SQL Server Authentication &sqlcmd -S SERVER -d DB -U LOGIN -P 'PASSWORD' -q 'select getdate()' - execute command-line query, connect using SQL Server Authentication, password prompt &sqlcmd -S SERVER -d DB -U LOGIN -q 'select getdate()' - execute command-line query, connect using Windows Authentication &sqlcmd -S SERVER -d DB -E -q 'select getdate()' - execute sql script file &sqlcmd -S SERVER -d DB -E -i x:\sql\script1.sql - execute all sql script files in a folder gci x:\sql\ *.* | %{ &sqlcmd -S SERVER -d DB -E -i $_.fullname } - exit or quit - command-line options [-? show syntax summary] [-a packetsize] [-A dedicated admin connection] [-b On error batch abort] [-c cmdend] [-C Trust Server Certificate] [-d use database name] [-e echo input] [-E trusted connection] [-f <codepage> | i:<codepage>[,o:<codepage>]] [-h headers] [-H hostname] [-i inputfile] [-I Enable Quoted Identifiers] [-k[1|2] remove[replace] control characters] [-l login timeout] [-L[c] list servers[clean output]] [-m errorlevel] [-N Encrypt Connection] [-o outputfile] [-p[1] print statistics[colon format]] [-P password] [-q "cmdline query"] [-Q "cmdline query" and exit] [-r[0|1] msgs to stderr] [-R use client regional setting] [-s colseparator] [-S server] [-t query timeout] [-u unicode output] [-U login id] [-v var = "value"...] [-V severitylevel] [-w screen width] [-W remove trailing spaces] [-x disable variable substitution] [-X[1] disable commands, startup script, enviroment variables [and exit]] [-y variable length type display width] [-Y fixed length type display width] [-z new password] [-Z new password and exit]
No comments:
Post a Comment