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

비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  39  40  41  42  [43]  44  45  ...
NoWriterDateCnt.TitleFile(s)
12551정성태3/5/20217339오류 유형: 702. 비주얼 스튜디오 - The 'CascadePackage' package did not load correctly. (2)
12550정성태3/5/20217038오류 유형: 701. Live Share 1.0.3713.0 버전을 1.0.3884.0으로 업데이트 이후 ContactServiceModelPackage 오류 발생하는 문제
12549정성태3/4/20217496오류 유형: 700. VsixPublisher를 이용한 등록 시 다양한 오류 유형 해결책
12548정성태3/4/20218278개발 환경 구성: 546. github workflow/actions에서 nuget 패키지 등록하는 방법
12547정성태3/3/20218794오류 유형: 699. 비주얼 스튜디오 - The 'CascadePackage' package did not load correctly.
12546정성태3/3/20218415개발 환경 구성: 545. github workflow/actions에서 빌드시 snk 파일 다루는 방법 - Encrypted secrets
12545정성태3/2/202111139.NET Framework: 1026. 닷넷 5에 추가된 POH (Pinned Object Heap) [10]
12544정성태2/26/202111324.NET Framework: 1025. C# - Control의 Invalidate, Update, Refresh 차이점 [2]
12543정성태2/26/20219719VS.NET IDE: 158. C# - 디자인 타임(design-time)과 런타임(runtime)의 코드 실행 구분
12542정성태2/20/202112050개발 환경 구성: 544. github repo의 Release 활성화 및 Actions를 이용한 자동화 방법 [1]
12541정성태2/18/20219303개발 환경 구성: 543. 애저듣보잡 - Github Workflow/Actions 소개
12540정성태2/17/20219623.NET Framework: 1024. C# - Win32 API에 대한 P/Invoke를 대신하는 Microsoft.Windows.CsWin32 패키지
12539정성태2/16/20219508Windows: 189. WM_TIMER의 동작 방식 개요파일 다운로드1
12538정성태2/15/20219902.NET Framework: 1023. C# - GC 힙이 아닌 Native 힙에 인스턴스 생성 - 0SuperComicLib.LowLevel 라이브러리 소개 [2]
12537정성태2/11/202110891.NET Framework: 1022. UI 요소의 접근은 반드시 그 UI를 만든 스레드에서! - 두 번째 이야기 [2]
12536정성태2/9/20219923개발 환경 구성: 542. BDP(Bandwidth-delay product)와 TCP Receive Window
12535정성태2/9/20219049개발 환경 구성: 541. Wireshark로 확인하는 LSO(Large Send Offload), RSC(Receive Segment Coalescing) 옵션
12534정성태2/8/20219673개발 환경 구성: 540. Wireshark + C/C++로 확인하는 TCP 연결에서의 closesocket 동작 [1]파일 다운로드1
12533정성태2/8/20219314개발 환경 구성: 539. Wireshark + C/C++로 확인하는 TCP 연결에서의 shutdown 동작파일 다운로드1
12532정성태2/6/20219830개발 환경 구성: 538. Wireshark + C#으로 확인하는 ReceiveBufferSize(SO_RCVBUF), SendBufferSize(SO_SNDBUF) [3]
12531정성태2/5/20218801개발 환경 구성: 537. Wireshark + C#으로 확인하는 PSH flag와 Nagle 알고리듬파일 다운로드1
12530정성태2/4/202112944개발 환경 구성: 536. Wireshark + C#으로 확인하는 TCP 통신의 Receive Window
12529정성태2/4/202110062개발 환경 구성: 535. Wireshark + C#으로 확인하는 TCP 통신의 MIN RTO [1]
12528정성태2/1/20219447개발 환경 구성: 534. Wireshark + C#으로 확인하는 TCP 통신의 MSS(Maximum Segment Size) - 윈도우 환경
12527정성태2/1/20219685개발 환경 구성: 533. Wireshark + C#으로 확인하는 TCP 통신의 MSS(Maximum Segment Size) - 리눅스 환경파일 다운로드1
12526정성태2/1/20217549개발 환경 구성: 532. Azure Devops의 파이프라인 빌드 시 snk 파일 다루는 방법 - Secure file
... 31  32  33  34  35  36  37  38  39  40  41  42  [43]  44  45  ...