256 Kilobytes

Answers in Databases | By Some Guy


358 views, 0 RAMs, and 1 comment

Tags: SQL, Binary Data, Errors, Server Error, String Data

Profile Photo - Some GuySome GuyBasic Subscriber

Over the past few weeks, I have been trying to pick up some SQL in my free time. It is going decently well, but I seem to be getting one error a lot and don't know how to fix it. The error is "string or binary data would be truncated." What is this, how can I fix it?

Download more RAM. 🐏 ⨉ 0Posted by Some Guy 2 years ago 🕓 Posted at 16 December, 2018 09:26 AM PST

This is a debug account.

Profile Photo - Hash BrownHash BrownInternet ActivistEnglandStaff


Trunication is basically where you're going to lose some of your data by inserting it. This is cause by trying to pass in data which is larger than the table allows.

For example, if you have passwords stored as a MD5 hash your table will have that column set up for 32 characters.

If you were to then change this MD5 to SHA2, your new password string would be 200 characters (from memory). The last 168 characters would not fit and would be lost.

Go through each column type and make sure the data you're passing in fits, when you find the error you can either:

  1. Alter the table structure to allow it.
  2. Validate data before it's sent to the table and reject it here.

Hope this helps.

Download more RAM. 🐏 ⨉ 0Posted by Hash Brown 2 years ago 🕓 Posted at 19 December, 2018 08:40 AM PST


Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account

Answers— Read More

Find more related content below!