Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

System.Data.SqlClient.SqlException - Arithmetic overflow error converting IDENTITY to data type int.

오호~~~ 테스트로 사용하는 DB 테이블로부터 다음과 같은 예외가 발생합니다.

System.Data.SqlClient.SqlException occurred
  HResult=0x80131904
  Message=Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.
  Source=.Net SqlClient Data Provider
  StackTrace:
   at WcfTest.HelloWorld(String connectionString) in D:\WcfTest.svc.cs:line 89

에러가 발생한 SQL은 "INSERT INTO Account(Name, Password) VALUES(@Name, @Password)"이었고 Account 테이블에 INSERT를 너무 많이 하다 보니 INT 타입의 IDENTITY 설정이 21억까지 진행한 것입니다.

http://stackoverflow.com/questions/2295731/maximum-for-autoincremental-int-primary-key-in-sqlserver
http://stackoverflow.com/questions/27040938/arithmetic-overflow-error-converting-identity-to-data-type-tinyint

저처럼 테스트 테이블이라면 그냥 단순하게 다음과 같이 날리셔도 됩니다.

Truncate Table [Account]

삽입/삭제를 반복해서 발생한 경우라면 IDENTITY로 증가한 것을 다시 0부터 진행하라고 명령을 내려도 되겠고,

DBCC CHECKIDENT(Account, RESEED,0)

아니면 보다 더 안전하게 bigint로 타입을 바꾸셔도 됩니다. SQL Server Management Studio의 경우 사용 중인 테이블의 디자인을 바꾸는 경우 다음과 같은 메시지를 띄우며 중단합니다.

Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.


Tools / Options를 통해 다음과 같이 "Prevent saving changes that require table re-creation" 옵션을 해제해 주면,

db_identity_1.png

제약 없이 테이블 디자인을 바꿀 수 있습니다. 이 옵션에 관한 좀 더 자세한 설명은 다음의 KB 자료에서 볼 수 있습니다.

Error message when you try to save a table in SQL Server: "Saving changes is not permitted"
; https://support.microsoft.com/en-us/help/956176/error-message-when-you-try-to-save-a-table-in-sql-server-saving-changes-is-not-permitted




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 3/28/2017]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12278정성태7/23/20209454VS.NET IDE: 149. ("Binary was not built with debug information" 상태로) 소스 코드 디버깅이 안되는 경우
12277정성태7/23/202010893개발 환경 구성: 498. DEVPATH 환경 변수의 사용 예 - .NET Reflector의 (PDB 연결이 없는) DLL의 소스 코드 디버깅
12276정성태7/23/202010084.NET Framework: 930. 개발자를 위한 닷넷 어셈블리 바인딩 - DEVPATH 환경 변수
12275정성태7/22/202012640개발 환경 구성: 497. 닷넷에서 접근해보는 InterSystems의 IRIS Data Platform 데이터베이스파일 다운로드1
12274정성태7/21/202012019개발 환경 구성: 496. Azure - Blob Storage Account의 Location 이전 방법 [1]파일 다운로드1
12273정성태7/18/202013646개발 환경 구성: 495. Azure - Location이 다른 웹/DB 서버의 경우 발생하는 성능 하락
12272정성태7/16/20208656.NET Framework: 929. (StrongName의 버전 구분이 필요 없는) .NET Core 어셈블리 바인딩 규칙 [2]파일 다운로드1
12271정성태7/16/202010715.NET Framework: 928. .NET Framework의 Strong-named 어셈블리 바인딩 (2) - 런타임에 바인딩 리디렉션파일 다운로드1
12270정성태7/16/202011539오류 유형: 633. SSL_CTX_use_certificate_file - error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
12269정성태7/16/20208553오류 유형: 632. .NET Core 웹 응용 프로그램 - The process was terminated due to an unhandled exception.
12268정성태7/15/202010704오류 유형: 631. .NET Core 웹 응용 프로그램 오류 - HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process
12267정성태7/15/202012369.NET Framework: 927. C# - 윈도우 프로그램에서 Credential Manager를 이용한 보안 정보 저장파일 다운로드1
12266정성태7/14/202010074오류 유형: 630. 사용자 계정을 지정해 CreateService API로 서비스를 등록한 경우 "Error 1069: The service did not start due to a logon failure." 오류발생
12265정성태7/10/20209230오류 유형: 629. Visual Studio - 웹 애플리케이션 실행 시 "Unable to connect to web server 'IIS Express'." 오류 발생
12264정성태7/9/202018295오류 유형: 628. docker: Error response from daemon: Conflict. The container name "..." is already in use by container "...".
12261정성태7/9/202011198VS.NET IDE: 148. 윈도우 10에서 .NET Core 응용 프로그램을 리눅스 환경에서 실행하는 2가지 방법 - docker, WSL 2 [5]
12260정성태7/8/20209603.NET Framework: 926. C# - ETW를 이용한 ThreadPool 스레드 감시파일 다운로드1
12259정성태7/8/20209133오류 유형: 627. nvlddmkm.sys의 BAD_POOL_HEADER BSOD 문제 [1]
12258정성태7/8/202012300기타: 77. DataDog APM 간략 소개
12257정성태7/7/20209331.NET Framework: 925. C# - ETW를 이용한 Monitor Enter/Exit 감시파일 다운로드1
12256정성태7/7/20209746.NET Framework: 924. C# - Reflection으로 변경할 수 없는 readonly 정적 필드 [4]
12255정성태7/6/202010176.NET Framework: 923. C# - ETW(Event Tracing for Windows)를 이용한 Finalizer 실행 감시파일 다운로드1
12254정성태7/2/202010017오류 유형: 626. git - REMOTE HOST IDENTIFICATION HAS CHANGED!
12253정성태7/2/202011093.NET Framework: 922. C# - .NET ThreadPool의 Local/Global Queue파일 다운로드1
12252정성태7/2/202013062.NET Framework: 921. C# - I/O 스레드를 사용한 비동기 소켓 서버/클라이언트파일 다운로드2
12251정성태7/1/202011030.NET Framework: 920. C# - 파일의 비동기 처리 유무에 따른 스레드 상황 [1]파일 다운로드2
... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...