4922: ALTER TABLE ALTER COLUMN failed because one or more objects access this column(1 つ以上のオブジェクトがこの列にアクセスしているため ALTER TABLE ALTER COLUMN が失敗)
SQL Server意味
列の型/プロパティを変更しようとしたが、その列に依存するオブジェクト (インデックス、制約、計算列、統計、スキーマバインドされたビューなど) が妨げた。依存関係を解消するまで列は変更できない。
原因
列がインデックス、PRIMARY KEY/UNIQUE/CHECK/DEFAULT 制約、計算列の式、WITH SCHEMABINDING で定義されたビュー/関数、または統計オブジェクトで使用されている。型/サイズの変更はそれらのオブジェクトを無効にするため、ALTER が拒否される。
対処方法
まず依存オブジェクトを特定して一時的に削除または無効化し、列を変更してから再作成する。依存関係の確認には sys.sql_expression_dependencies と sys.indexes/sys.default_constraints を照会する。一般的な順序: DROP CONSTRAINT/INDEX -> ALTER COLUMN -> 再度 CREATE。スキーマバインドされたビューでは、一時的に SCHEMABINDING を外してから付け直す。
同じデータベースの他の項目
- 15023User already exists in the current database(ユーザーは現在のデータベースに既に存在する)
- 18452Login failed. The login is from an untrusted domain and cannot be used with Windows authentication(ログイン失敗。信頼されていないドメインからのログインで Windows 認証に使用できない)
- 605Attempt to fetch logical page belongs to a different allocation unit(取得しようとした論理ページが別のアロケーションユニットに属する)
- 7202Could not find server 'name' in sys.servers(sys.servers にサーバー 'name' が見つからない)
- 40501The service is currently busy. Retry the request after 10 seconds(サービスは現在ビジー。10 秒後に要求を再試行)
- 8645A time out occurred while waiting for memory resources to execute the query(クエリ実行用のメモリリソース待機中にタイムアウト発生)
- 8651Could not perform the operation because the requested memory grant was not available(要求されたメモリ許可が利用できないため操作を実行できない)