4922: ALTER TABLE ALTER COLUMN failed because one or more objects access this column (하나 이상의 객체가 이 컬럼에 접근하므로 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 (가져오려는 논리 페이지가 다른 allocation unit에 속함)
- 7202Could not find server 'name' in sys.servers (sys.servers에서 서버를 찾을 수 없음)
- 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 (요청한 memory grant를 사용할 수 없어 작업을 수행할 수 없음)