"No","テストID","対象ファイル","対象クラス/関数","対象メソッド","テスト観点","テストケース名","前提条件","入力値","期待結果","優先度","備考"
"1","UT-IED-001","sp_ineachdb.sql","sp_ineachdb","@Help","正常系","ヘルプ表示が正常に動作すること","プロシージャがインストール済み","@Help=1","ヘルプメッセージが出力され、-1が返却される","中","Help機能の基本動作確認"
"2","UT-IED-002","sp_ineachdb.sql","sp_ineachdb","@VersionCheckMode","正常系","バージョンチェックモードで即座に終了すること","プロシージャがインストール済み","@VersionCheckMode=1","処理が即座に終了し、@Version, @VersionDateが設定される","中","バージョン確認機能"
"3","UT-IED-003","sp_ineachdb.sql","sp_ineachdb","@Version/@VersionDate","正常系","バージョン情報が正しく返却されること","プロシージャがインストール済み","@Version=NULL OUTPUT, @VersionDate=NULL OUTPUT","@Version='8.29', @VersionDate='20260203'が設定される","低","OUTPUT パラメータ確認"
"4","UT-IED-004","sp_ineachdb.sql","sp_ineachdb","@command","正常系","基本的なコマンドが全データベースで実行されること","複数のユーザーデータベースが存在","@command=N'SELECT DB_NAME()'","各データベースでコマンドが実行され結果が返却される","高","基本機能の動作確認"
"5","UT-IED-005","sp_ineachdb.sql","sp_ineachdb","@command","異常系","NULLコマンドが渡された場合の挙動","プロシージャがインストール済み","@command=NULL","エラーまたは空の結果（データベースに対して何も実行されない）","中","NULLハンドリング"
"6","UT-IED-006","sp_ineachdb.sql","sp_ineachdb","@command","異常系","空文字列コマンドが渡された場合の挙動","プロシージャがインストール済み","@command=N''","エラーまたは空の結果","中","空文字列ハンドリング"
"7","UT-IED-007","sp_ineachdb.sql","sp_ineachdb","@command","異常系","構文エラーを含むコマンドの実行","プロシージャがインストール済み","@command=N'SELEC * FRM invalid'","RAISERRORでエラーメッセージが出力され、次のDBへ処理継続","高","エラーハンドリング確認"
"8","UT-IED-008","sp_ineachdb.sql","sp_ineachdb","@replace_character","正常系","置換文字でデータベース名が正しく置換されること","複数データベースが存在","@command=N'SELECT ''?'' AS DbName', @replace_character=N'?'","?がデータベース名に置換される","高","置換文字機能の基本動作"
"9","UT-IED-009","sp_ineachdb.sql","sp_ineachdb","@replace_character","正常系","カスタム置換文字が正しく動作すること","複数データベースが存在","@command=N'SELECT ''#'' AS DbName', @replace_character=N'#'","#がデータベース名に置換される","中","カスタム置換文字"
"10","UT-IED-010","sp_ineachdb.sql","sp_ineachdb","@replace_character","境界値","コマンド内に置換文字が存在しない場合","複数データベースが存在","@command=N'SELECT 1', @replace_character=N'?'","コマンドがそのまま実行される","低","置換不要ケース"
"11","UT-IED-011","sp_ineachdb.sql","sp_ineachdb","@print_dbname","正常系","データベース名が出力されること","複数データベースが存在","@command=N'SELECT 1', @print_dbname=1","各DBの処理前に/* [DatabaseName] */形式でDB名が出力される","中","デバッグ・確認用機能"
"12","UT-IED-012","sp_ineachdb.sql","sp_ineachdb","@select_dbname","正常系","データベース名がSELECT結果として返却されること","複数データベースが存在","@command=N'SELECT 1', @select_dbname=1","各DBで[ineachdb current database]列にDB名が返却される","中","結果セットでのDB名確認"
"13","UT-IED-013","sp_ineachdb.sql","sp_ineachdb","@print_command","正常系","実行コマンドが出力されること","複数データベースが存在","@command=N'SELECT 1', @print_command=1","各DBの実行前にコマンド内容が出力される","中","デバッグ用コマンド表示"
"14","UT-IED-014","sp_ineachdb.sql","sp_ineachdb","@print_command_only","正常系","コマンドが出力のみで実行されないこと","複数データベースが存在","@command=N'SELECT 1', @print_command_only=1","コマンドが出力されるが実際には実行されない","高","ドライラン機能"
"15","UT-IED-015","sp_ineachdb.sql","sp_ineachdb","@suppress_quotename","正常系","QUOTENAME抑制でDB名がそのまま使用されること","複数データベースが存在","@command=N'SELECT ''?''', @suppress_quotename=1","DB名が[]なしで置換される","中","特殊なDB名ハンドリング"
"16","UT-IED-016","sp_ineachdb.sql","sp_ineachdb","@suppress_quotename","異常系","特殊文字を含むDB名でQUOTENAME抑制時の挙動","特殊文字を含むDB名が存在","@command=N'USE ?', @suppress_quotename=1","SQLインジェクションリスクがあるため注意が必要","高","セキュリティ考慮"
"17","UT-IED-017","sp_ineachdb.sql","sp_ineachdb","@system_only","正常系","システムDBのみが対象となること","システムDBとユーザーDBが存在","@command=N'SELECT DB_NAME()', @system_only=1","master, model, msdb, tempdb, distributorのみ処理される","高","フィルタリング機能"
"18","UT-IED-018","sp_ineachdb.sql","sp_ineachdb","@user_only","正常系","ユーザーDBのみが対象となること","システムDBとユーザーDBが存在","@command=N'SELECT DB_NAME()', @user_only=1","ユーザーDBのみ処理される（system DB除外）","高","フィルタリング機能"
"19","UT-IED-019","sp_ineachdb.sql","sp_ineachdb","@system_only/@user_only","異常系","両方1が指定された場合の挙動","システムDBとユーザーDBが存在","@system_only=1, @user_only=1","処理対象DBが0件となりエラー","中","矛盾するパラメータ"
"20","UT-IED-020","sp_ineachdb.sql","sp_ineachdb","@name_pattern","正常系","パターンに一致するDBのみ処理されること","Test%, Prod%などのDBが存在","@command=N'SELECT DB_NAME()', @name_pattern=N'Test%'","Test%に一致するDBのみ処理される","高","名前パターンフィルタ"
"21","UT-IED-021","sp_ineachdb.sql","sp_ineachdb","@name_pattern","境界値","パターンが%（デフォルト）の場合","複数DBが存在","@command=N'SELECT 1', @name_pattern=N'%'","全DBが対象となる","低","デフォルト動作確認"
"22","UT-IED-022","sp_ineachdb.sql","sp_ineachdb","@name_pattern","異常系","一致するDBが存在しないパターン","複数DBが存在","@command=N'SELECT 1', @name_pattern=N'NonExistent%'","'No databases to process.'エラー","中","該当なしケース"
"23","UT-IED-023","sp_ineachdb.sql","sp_ineachdb","@database_list","正常系","指定したDBリストのみ処理されること","master, tempdb, userdbが存在","@command=N'SELECT DB_NAME()', @database_list=N'master,tempdb'","master, tempdbのみ処理される","高","明示的DB指定"
"24","UT-IED-024","sp_ineachdb.sql","sp_ineachdb","@database_list","正常系","角括弧付きDB名が正しく解析されること","[My Database]が存在","@command=N'SELECT DB_NAME()', @database_list=N'[My Database]'","角括弧内のDB名が正しく認識される","高","特殊文字対応"
"25","UT-IED-025","sp_ineachdb.sql","sp_ineachdb","@database_list","境界値","1件のみ指定した場合","指定DBが存在","@command=N'SELECT 1', @database_list=N'master'","masterのみ処理される","中","単一DB指定"
"26","UT-IED-026","sp_ineachdb.sql","sp_ineachdb","@database_list","異常系","存在しないDB名を含むリスト","一部DBが存在しない","@command=N'SELECT 1', @database_list=N'master,NonExistentDB'","存在するDBのみ処理される","中","部分一致ケース"
"27","UT-IED-027","sp_ineachdb.sql","sp_ineachdb","@exclude_pattern","正常系","パターンに一致するDBが除外されること","Test%, Prod%などのDBが存在","@command=N'SELECT DB_NAME()', @exclude_pattern=N'Test%'","Test%に一致するDBが除外される","高","除外パターンフィルタ"
"28","UT-IED-028","sp_ineachdb.sql","sp_ineachdb","@exclude_list","正常系","指定したDBリストが除外されること","master, tempdb, userdbが存在","@command=N'SELECT DB_NAME()', @exclude_list=N'master,tempdb'","master, tempdb以外が処理される","高","明示的DB除外"
"29","UT-IED-029","sp_ineachdb.sql","sp_ineachdb","@database_list/@exclude_list","正常系","includeとexcludeの組み合わせ","複数DBが存在","@database_list=N'master,tempdb,msdb', @exclude_list=N'tempdb'","master, msdbのみ処理（excludeが優先）","高","フィルタ優先順位"
"30","UT-IED-030","sp_ineachdb.sql","sp_ineachdb","@recovery_model_desc","正常系","指定した復旧モデルのDBのみ処理されること","FULL, SIMPLEの両方のDBが存在","@command=N'SELECT DB_NAME()', @recovery_model_desc=N'FULL'","FULLリカバリモデルのDBのみ処理","中","復旧モデルフィルタ"
"31","UT-IED-031","sp_ineachdb.sql","sp_ineachdb","@recovery_model_desc","境界値","無効な復旧モデル名が指定された場合","複数DBが存在","@recovery_model_desc=N'INVALID'","対象DBが0件となりエラー","低","無効値ハンドリング"
"32","UT-IED-032","sp_ineachdb.sql","sp_ineachdb","@compatibility_level","正常系","指定した互換性レベルのDBのみ処理されること","異なる互換性レベルのDBが存在","@command=N'SELECT DB_NAME()', @compatibility_level=150","互換性レベル150のDBのみ処理","中","互換性レベルフィルタ"
"33","UT-IED-033","sp_ineachdb.sql","sp_ineachdb","@state_desc","正常系","ONLINE状態のDBのみ処理されること（デフォルト）","ONLINE, OFFLINEのDBが存在","@command=N'SELECT 1', @state_desc=N'ONLINE'","ONLINEのDBのみ処理される","高","状態フィルタ"
"34","UT-IED-034","sp_ineachdb.sql","sp_ineachdb","@state_desc","正常系","OFFLINE状態のDBを対象にできること","OFFLINEのDBが存在","@command=N'SELECT 1', @state_desc=N'OFFLINE'","OFFLINEのDBが処理対象となる","中","非ONLINE状態対応"
"35","UT-IED-035","sp_ineachdb.sql","sp_ineachdb","@is_read_only","正常系","読み取り専用DBのみ処理されること","読み取り専用と読み書きDBが存在","@command=N'SELECT DB_NAME()', @is_read_only=1","読み取り専用DBのみ処理","中","読み取り専用フィルタ"
"36","UT-IED-036","sp_ineachdb.sql","sp_ineachdb","@is_auto_close_on","正常系","AUTO_CLOSEが有効なDBのみ処理されること","AUTO_CLOSE ON/OFFのDBが存在","@command=N'SELECT DB_NAME()', @is_auto_close_on=1","AUTO_CLOSE有効DBのみ処理","低","AUTO_CLOSEフィルタ"
"37","UT-IED-037","sp_ineachdb.sql","sp_ineachdb","@is_auto_shrink_on","正常系","AUTO_SHRINKが有効なDBのみ処理されること","AUTO_SHRINK ON/OFFのDBが存在","@command=N'SELECT DB_NAME()', @is_auto_shrink_on=1","AUTO_SHRINK有効DBのみ処理","低","AUTO_SHRINKフィルタ"
"38","UT-IED-038","sp_ineachdb.sql","sp_ineachdb","@is_broker_enabled","正常系","Service Brokerが有効なDBのみ処理されること","Broker ON/OFFのDBが存在","@command=N'SELECT DB_NAME()', @is_broker_enabled=1","Service Broker有効DBのみ処理","低","Service Brokerフィルタ"
"39","UT-IED-039","sp_ineachdb.sql","sp_ineachdb","@user_access","正常系","MULTI_USERのDBのみ処理されること","MULTI_USER, SINGLE_USERのDBが存在","@command=N'SELECT DB_NAME()', @user_access=N'MULTI_USER'","MULTI_USERのDBのみ処理","中","ユーザーアクセスフィルタ"
"40","UT-IED-040","sp_ineachdb.sql","sp_ineachdb","@user_access","正常系","SINGLE_USERのDBのみ処理されること","SINGLE_USERのDBが存在","@command=N'SELECT DB_NAME()', @user_access=N'SINGLE_USER'","SINGLE_USERのDBのみ処理","中","SINGLE_USERフィルタ"
"41","UT-IED-041","sp_ineachdb.sql","sp_ineachdb","@user_access","正常系","RESTRICTED_USERのDBのみ処理されること","RESTRICTED_USERのDBが存在","@command=N'SELECT DB_NAME()', @user_access=N'RESTRICTED_USER'","RESTRICTED_USERのDBのみ処理","中","RESTRICTED_USERフィルタ"
"42","UT-IED-042","sp_ineachdb.sql","sp_ineachdb","@user_access","異常系","無効なuser_access値が指定された場合","複数DBが存在","@user_access=N'INVALID_ACCESS'","フィルタが適用されず全DB処理または0件","低","無効値ハンドリング"
"43","UT-IED-043","sp_ineachdb.sql","sp_ineachdb","@is_ag_writeable_copy","正常系","AG書き込み可能コピーのみ処理されること","AG構成の環境","@command=N'SELECT DB_NAME()', @is_ag_writeable_copy=1","プライマリレプリカのDBのみ処理","高","AG対応フィルタ"
"44","UT-IED-044","sp_ineachdb.sql","sp_ineachdb","@is_ag_writeable_copy","正常系","非AG環境での動作","AG未構成の環境","@command=N'SELECT 1', @is_ag_writeable_copy=1","全対象DBが処理される（AG関連フィルタは影響なし）","中","非AG環境対応"
"45","UT-IED-045","sp_ineachdb.sql","sp_ineachdb","@is_query_store_on","正常系","Query Storeが有効なDBのみ処理されること","SQL Server 2016以降、QS ON/OFFのDBが存在","@command=N'SELECT DB_NAME()', @is_query_store_on=1","Query Store有効DBのみ処理","中","Query Storeフィルタ"
"46","UT-IED-046","sp_ineachdb.sql","sp_ineachdb","@is_query_store_on","正常系","Query Storeが無効なDBのみ処理されること","SQL Server 2016以降","@command=N'SELECT DB_NAME()', @is_query_store_on=0","Query Store無効DBのみ処理","中","Query Store無効フィルタ"
"47","UT-IED-047","sp_ineachdb.sql","sp_ineachdb","@is_query_store_on","境界値","SQL Server 2016未満での動作","SQL Server 2014以前","@command=N'SELECT 1', @is_query_store_on=1","Query Storeフィルタが無視される（バージョンチェック）","中","下位バージョン互換性"
"48","UT-IED-048","sp_ineachdb.sql","sp_ineachdb","複合フィルタ","正常系","複数のフィルタ条件を組み合わせた処理","様々な属性のDBが存在","@user_only=1, @recovery_model_desc=N'FULL', @is_read_only=0","全条件に一致するDBのみ処理","高","複合条件フィルタ"
"49","UT-IED-049","sp_ineachdb.sql","sp_ineachdb","処理対象なし","異常系","全DBがフィルタで除外された場合","DBが存在","@name_pattern=N'NonExistent%'","'No databases to process.'がRAISERROR(severity 1)で出力","高","対象なしエラー処理"
"50","UT-IED-050","sp_ineachdb.sql","sp_ineachdb","AG セカンダリ","正常系","AGセカンダリで接続不可DBが除外されること","AG構成、secondary_role_allow_connections=0","@command=N'SELECT DB_NAME()'","接続不可のセカンダリDBが除外される","高","AG セカンダリ対応"
"51","UT-IED-051","sp_ineachdb.sql","sp_ineachdb","HAS_DBACCESS","正常系","アクセス権のないDBが除外されること","一部DBにアクセス権なし","@command=N'SELECT DB_NAME()'","HAS_DBACCESS=0のDBが除外される","高","アクセス権チェック"
"52","UT-IED-052","sp_ineachdb.sql","sp_ineachdb","inaccessible state","正常系","アクセス不可状態のDBが除外されること","RESTORING状態のDBが存在","@command=N'SELECT 1'","state & 992 <> 0のDBが除外される","高","アクセス不可状態除外"
"53","UT-IED-053","sp_ineachdb.sql","sp_ineachdb","Collation check","正常系","Collationが取得できないDBが除外されること","部分的にオンラインのDBが存在","@command=N'SELECT 1'","DATABASEPROPERTYEX(name, 'Collation') IS NULLのDBが除外","中","部分オンライン除外"
"54","UT-IED-054","sp_ineachdb.sql","sp_ineachdb","distributor DB","正常系","distributorデータベースがシステムDBとして扱われること","レプリケーション構成でdistributorが存在","@command=N'SELECT DB_NAME()', @system_only=1","distributorがシステムDBとして処理される","中","distributor対応"
"55","UT-IED-055","sp_ineachdb.sql","sp_ineachdb","カーソル処理","正常系","大量のデータベースでも正常に処理されること","50以上のDBが存在","@command=N'SELECT DB_NAME()'","全対象DBでコマンドが実行される","中","大量DB処理"
"56","UT-IED-056","sp_ineachdb.sql","sp_ineachdb","エラー継続","正常系","1つのDBでエラーが発生しても他DBの処理が継続すること","権限不足のDBが一部存在","@command=N'SELECT * FROM sys.objects'","エラーDBはRAISERRORで通知、他DBは処理継続","高","エラー時継続処理"
"57","UT-IED-057","sp_ineachdb.sql","sp_ineachdb","シングルクォート","正常系","DB名にシングルクォートが含まれる場合の処理","[Test'DB]が存在","@command=N'SELECT ''?'''","シングルクォートが適切にエスケープされる","高","SQLインジェクション対策"
"58","UT-IED-058","sp_ineachdb.sql","sp_ineachdb","角括弧エスケープ","正常系","DB名に角括弧が含まれる場合の処理","[Test]]DB]が存在","@command=N'SELECT ''?''', @database_list=N'[Test]]DB]'","エスケープされた角括弧が正しく解析される","中","角括弧エスケープ"
"59","UT-IED-059","sp_ineachdb.sql","sp_ineachdb","空白文字処理","正常系","DB名リストの空白文字が適切に処理されること","複数DBが存在","@database_list=N' master , tempdb '","前後の空白が除去されDBが正しく認識される","中","空白文字トリミング"
"60","UT-IED-060","sp_ineachdb.sql","sp_ineachdb","SET NOCOUNT","正常系","NOCOUNT ONで余分なメッセージが抑制されること","複数DBが存在","@command=N'INSERT INTO #temp VALUES(1)'","'(1 row affected)'等のメッセージが抑制される","低","出力制御"
"61","UT-IED-061","sp_ineachdb.sql","sp_ineachdb","SET STATISTICS XML OFF","正常系","統計XMLが出力されないこと","複数DBが存在","@command=N'SELECT 1'","統計情報XMLが出力に含まれない","低","出力制御"
"62","UT-IED-062","sp_ineachdb.sql","sp_ineachdb","sp_executesql","正常系","各DBコンテキストでsp_executesqlが正しく実行されること","複数DBが存在","@command=N'SELECT DB_NAME() AS CurrentDB'","各DBのコンテキストでコマンドが実行される","高","実行コンテキスト確認"
"63","UT-IED-063","sp_ineachdb.sql","sp_ineachdb","model DB + Query Store","境界値","SQL Server 2022+でmodelのQS除外が正しく動作すること","SQL Server 2022以降","@command=N'SELECT 1', @is_query_store_on=1","modelデータベースがQSフィルタから適切に除外される","中","SQL Server 2022対応"
"64","UT-IED-064","sp_ineachdb.sql","sp_ineachdb","@print_dbname + @print_command","正常系","複数出力オプションの同時使用","複数DBが存在","@command=N'SELECT 1', @print_dbname=1, @print_command=1","DB名とコマンドの両方が出力される","低","複合出力オプション"
"65","UT-IED-065","sp_ineachdb.sql","sp_ineachdb","改行文字","正常系","コマンド出力時の改行が正しく処理されること","複数DBが存在","@command=N'SELECT 1; SELECT 2', @print_command=1","CRLF(CHAR(13)+CHAR(10))で改行される","低","改行文字処理"
