String or binary data would be truncated

 

When we want to add data to a table, we get this error if the size of the column in the table is smaller than the data we want to add.

For example, with the help of the following script, let’s create a table named databaseandlogins in the TestDB database.

Then try to add data to this table as follows.

When we try to add data in this way, we will get an error as follows.

To overcome this problem, we must increase the size of the column named database_name, which we have defined as varchar(10). To increase the size of a column in SQL Server , you can read my article “ALTER TABLE Statement in SQL Server(TSQL)

dbtut
Author: dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *