SSブログ

SQL ServerのCLI管理ツールオプションまとめ(2012) [SQL Server]

思うところあってSQL ServerのCLI管理ツールであるisql,osql,sqlcmdのオプションの違いをまとめてみました。



結論、非互換的な注意点としては以下かと思います。
Dはosqlだけ
nはisql,osqlだけ
Oはisql,osqlだけ
xはisqlとsqlcmdだけだが機能が違う

http://msdn.microsoft.com/en-us/library/aa214007%28v=sql.80%29.aspx
http://msdn.microsoft.com/ja-jp/library/ms162806.aspx
http://technet.microsoft.com/ja-jp/library/ms162773.aspx

以下まとめ表です。Excelでもあるのでご入り用の方はご連絡を。
説明列は上記URLから初出時の説明をコピペしています。(途中で切れているものあり)
なのでisqlからの記載は英語です。


スポンサードリンク




id op desc 2000 isql 2012 osql 2012 sqlcmd
1 L Lists the locally configured servers and the names of the servers broadcasting = on the network.
2 U Is the user login ID. Login IDs are case-sensitive.
3 P Is a user-specified password. If the -P option is not used, isql prompts for= a password. If the -P option is used at the end of the command prompt witho= ut any password, isql uses the default password (NULL).
4 E Uses a trusted connection instead of requesting a password.
5 S Specifies the default instance of SQL Server to connect to. isql does not support connecting to a named instance of SQL Server 2000. If no server is specif= ied, isql connects to the default instance of SQL Server on the local computer. This option is required if you are executing isql from a remote computer.=
6 H Is a workstation name. The workstation name is stored in sysprocesses.hostna= me and is displayed by sp_who. If not specified, the current computer name is assumed.
7 d  Issues a USE db_name statement when isql is started.
8 l  Specifies the number of seconds before an isql login times out. If no time= _out value is specified, a command runs indefinitely. The defa= ult time-out for login to isql is eight seconds.
9 t  Specifies the number of seconds before a command times out. If no time_out value is specified, a command runs indefinitely; the default time-out for logging = in to isql is eight seconds.
10 h  Specifies the number of rows to print between column headings. The default is to pr= int headings one time for each set of query results. Use -1 to specify that no headers will be printed. If using -1, there must be no space between the parameter and the setting (-h-1, not -h -1).
11 s  Specifies the column-separator character, which is a blank space by default. To use characters that have special meaning to the operating system (for example= , | ; & < >), enclose the character in double quotation marks (&quo= t;).
12 w  Allows the user to set the screen width for output. The default is 80 characters. When an output line has reached its maximum screen width, it is broken in= to multiple lines.
13 a  Allows you to request a different-sized packet. The valid values for packet_size= are 512 through 65535. The default value for the Microsoft Windows NT® ve= rsion of isql is 8192; otherwise, the default value is 512 for Microsoft MS-DOS&re= g;, although larger sizes can be requested with that version as well. Increas= ed packet size can enhance performance on larger script execution where the amount of SQL statements between GO commands is substantial. Microsoft testing indicates that 8192 is typically the fastest setting for bulk copy operations. A larger packet size can be requested, but isql defaults to 5= 12 if the request cannot be granted.
14 e Echoes input.
15 I  QUOTED_IDENTIFIER 接続オプションを有効にします。 ×
16 D  SQL Server 用の ODBC ドライバーを= 使用して定義された ODBC データ ソースに接続します。 osql 接続では、データ ソースで指定されたオプ・ Vョンが使用されます。  × ×
17 x  Specifies, in bytes, the maximum length of text data to return. Text values longer t= han max_text_size are truncated. If max_text_size is not specified, text data= is truncated at 4096 bytes. × ×
18 c  Specifies the command terminator. By default, commands are terminated and sent to S= QL Server 2000 by entering GO on a line by itself. When you reset the command terminator, do not use Transact-SQL reserved words or characters that have special meaning to the operating system, whether preceded by a backslash = or not.
19 q  Executes a query when isql starts, but does not exit isql when the query completes. (Note that the query statement should not include GO). If you issue a que= ry from a batch file, you can use %variables. Environment %variables% also w= ork. For example:
20 Q  Executes a query and immediately exits isql when the query completes. Use double quotation marks around the query and single quotation marks around anythi= ng embedded in the query.
21 n Removes numbering and the prompt symbol (>) from input lines. ×
22 m  Customizes the display of error messages. The message number, state, and error level= are displayed for errors of the specified severity level or higher. Nothing is displayed for errors of severity levels lower than the specified level. U= se -1 to specify that all headers are returned with messages, even informati= onal messages. If -1 is used, there must be no space between the parameter and= the setting (-m-1, not -m -1).
23 r  Redirects message output to the screen (stderr). If you do not specify a parameter,= or if you specify 0, only error messages with severity 11 or higher are redirected. If you specify 1, all message output (including "print") is redirected.
24 i  Identifies the file that contains a batch of SQL statements or stored procedures. The less than (<) comparison operator can be used in place of -i.
25 o  Identifies the file that receives output from isql. The greater than (>) comparis= on operator can be used in place of -o.
26 p Prints performance statistics.
27 b Specifies that isql exits and returns a DOS ERRORLEVEL value when an error occurs. = The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server er= ror message has a severity of 10 or greater; otherwise, the value returned is= 0. MS-DOS batch files can test the value of DOS ERRORLEVEL and handle the er= ror appropriately.
28 u input_file の形式に関係なく、output_file を Unicode 形式で格納します。 ×
29 R  通貨、日付、および時刻データを文字データに変換するときに、SQL Server ODBC ドライバーでクライアントの設定を使用することを指定します。 ×
30 O Specifies that isql reverts to the behavior of earlier versions. These features are deactivated:  ×
31 A 専用管理者接続 (DAC) を使用して SQL Server にログインします。 この種類の接続は、サーバー= のトラブルシューティングで使用されます。 またこの接続は、DAC をサポートしているサーバー コンピューターでのみ機能し= ます。 DAC が使用できない場合は、sqlcmd はエラー メッセージを生成して終了します。 DAC の詳細については、「データベース管理= 者用の診断接続」を参照してください。 × ×
32 C クライアントでこのスイッチを使用して、サーバーの証明書を検証せず= に暗黙的に信頼するようにクライアントを構成できます。 このオプションは、ADO.NET オプションの TRUSTSERVERCERTIFICATE =3D true と= 同等です。 × ×
33 K  アプリケーションがサーバーに接続するときのワークロードのタイプを= 宣言します。 現在サポートされている値は、ReadOnly だけです。 -K を指定しない場合、sqlc= md ユーティリティでは AlwaysOn 可用性グループのセカンダリ レプリカへの接続がサポートされません。 詳細に・ ツいては、「アクティブなセカンダリ: 読み取り可能なセカンダリ レプリカ (AlwaysOn 可用性グループ)」を参照してください。 × ×
34 M  SQL Server 2012 可用性グループまたは SQL Server 2012 フェールオーバー クラス・ ^ー インスタンスの可用性グループ リスナーに接続する際には、必ず -M を指定してください。 -M を指定すると、(= 現在) アクティブなサーバーを迅速に検出して接続できます。 –M が指定されていない場合、-M は無効になります。 AlwaysOn 可用性グループ の・ レ細については、「可用性グループ リスナー、クライアント接続、およびアプリケーションのフェールオーバー (SQL= Server)」、「可用性グループの作成と構成 (SQL Server)」、「フェールオーバー クラスタリングと AlwaysOn 可用性グループ (S= QL Server)」、および「アクティブなセカンダリ: 読み取り可能なセカンダリ レプリカ (AlwaysOn 可用性グループ)」を参照してく= ださい。 × ×
35 N クライアントでこのスイッチを使用して、暗号化された接続を要求でき= ます。 × ×
36 z パスワードの変更:
    sqlcmd -U so= meuser -P s0mep@ssword -z a_new_p@a$$w0rd
× ×
37 Z  パスワードの変更と終了:
    sqlcmd -U so= meuser -P s0mep@ssword -Z a_new_p@a$$w0rd
× ×
38 f 入力と出力のコード ページを指定します。 コード ページ番号は、インストールされた Windows コー= ド ページを指定する数値です。  × ×
39 v sqlcmd スクリプトで使用できる sqlcmd スクリプト変数を作成します。 値に空白が含ま= れる場合は、値を引用符で囲みます。 複数の var=3D"values" の値を指定できます。 指定した値にエラーが生じた・ 鼾№ヘ、sqlcmd は、エラー メッセージを生成してから終了します。&nbs= p; × ×
40 x  sqlcmd ではスクリプト変数が無視されます。 これは、$(variable_name) などの通常の・ マ数と同じ形式の文字列を含む INSERT ステートメントが、スクリプトに多数含まれている場合に便利です。 × ×
41 k  タブ、改行文字などのすべての制御文字を出力から削除します。 これにより、データが返されたときの列の形式が維持されます。 1 を指定した場= 合、制御文字は 1 つの空白に置き換えられます。 2 を指定すると、連続する制御文字が 1 つの空白に置き換えられます。 -k は -k1= と同じです。 × ×
42 W このオプションは、列から後続の空白を削除します。 他のアプリケーションにエクスポートするデータを準備するときは、-s オプショ= ンと同時にこのオプションを使用します。 -y または -Y オプションと共には使用できません。 × ×
43 y  sqlcmd スクリプト変数 SQLCMDMAXFI= XEDTYPEWIDTH が設定されます。 既定値は 256 です。 長い可変長のデータ型に返される文字数= を制限します。  × ×
44 Y   sqlcmd スクリプト変数 SQLCMDMAXVA= RTYPEWIDTH が設定されます。 既定値は 0 (無制限) です。 次のデータ型に返される文字数・ ァ限します。  × ×
45 V  ERRORLEVEL 変数を設定するために使用される重大度レベルを制御します。 重大度レベルがこ= の値以上のエラー メッセージによって、ERRORLEVEL が設定されます。 0 より小さい値は 0 と報告されます。 バッチ ファイルおよび CMD ファイルを使・ pして、ERRORLEVEL 変数の値をテストできます。 × ×
46 X  sqlcmd がバッチ ファイルから実行される場合に、システムのセキュリティを損なう可能性のある・ Rマンドを無効にします。 無効なコマンドも認識されます。sqlcmd は警告メッセージを表示して継続します。 省略可能なパラメーターを 1 に指定・ キると、sqlcmd はエラー メッセージを生成して終了します。 -X オプションを使用した場合に無効になるコマンドは次のとおりです。  × ×


nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:仕事

nice! 0

コメント 0

コメントを書く

お名前:[必須]
URL:[必須]
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。