2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQL Error 文字列データまたはバイナリ データが切り捨てられます

Posted at

データベースへのインサートにて

「文字列データまたはバイナリ データが切り捨てられます。」

というエラーがログが表示

原因

データベースに対し、設定カラムのサイズよりも大きいサイズの値を登録しようとすると発生するエラー

  • 入力フォームからの登録において、正しくバリデーションができていないことが原因
  • データベースのデータ定義をもとに入力値に対するガードが十分でない
e.g.
データ型 nVarchar(20)に、定義した値を超えた文字列を入れる

解消方法

カラムのサイズと値を確認して、どちらかを修正
特に全角と半角のバイト数に注意して、データ定義とバリデーションの設定をする必要がある

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?