SQL Server Error String or binary data would be truncated

0 votes

My table :

log_id                 bigint
old_value                  xml
new_value                  xml
module                 varchar(50)
reference_id           bigint
[transaction]          varchar(100)
transaction_status         varchar(10)
stack_trace                ntext
modified_on                datetime
modified_by                bigint

Insert Query :

INSERT INTO [dbo].[audit_log]
           ([old_value],[new_value],[module],[reference_id],[transaction]
           ,[transaction_status],[stack_trace],[modified_on],[modified_by])
     VALUES
            ('asdf','asdf','Subscriber',4,'_transaction',
            '_transaction_status','_stack_trace',getdate(),555)

Error :

Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.

Why is this error happening? Can someone please help me solve this?

Sep 13, 2022 in Database by Kithuzzz
• 38,000 points
5,997 views

1 answer to this question.

0 votes
You're trying to write more data than a specific column can store. Check the sizes of the data you're trying to insert against the sizes of each of the fields.

In this case transaction_status is a varchar(10) and you're trying to store 19 characters to it. I hope this helps you.
answered Sep 15, 2022 by narikkadan
• 63,600 points

Related Questions In Database

0 votes
0 answers

Error converting data type nvarchar to datetime SQL Server

I encountered this error: Error converting data type ...READ MORE

Aug 15, 2022 in Database by Kithuzzz
• 38,000 points
3,445 views
0 votes
0 answers

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

I experimented with the following code in ...READ MORE

Aug 22, 2022 in Database by Kithuzzz
• 38,000 points
6,472 views
0 votes
0 answers

SQL Server : Arithmetic overflow error converting expression to data type int

I'm getting this error: msg 8115, level 16, ...READ MORE

Aug 26, 2022 in Database by Kithuzzz
• 38,000 points
1,152 views
0 votes
0 answers
0 votes
1 answer

SQL Server CASE .. WHEN .. IN statement

Two forms of CASE statements are getting ...READ MORE

answered Feb 8, 2022 in Database by Vaani
• 7,070 points
693 views
0 votes
0 answers

Selecting COUNT(*) with DISTINCT

In SQL Server 2005, I have a ...READ MORE

Feb 14, 2022 in Database by Neha
• 9,020 points
491 views
0 votes
1 answer

SQL Server CASE .. WHEN .. IN statement

Try this... SELECT AlarmEventTransactionTableTable.TxnID, ...READ MORE

answered Jun 14, 2022 in Others by polo
• 1,480 points
516 views
0 votes
0 answers

Simple DateTime sql query

How do I query the DateTime database ...READ MORE

Aug 12, 2022 in Database by Kithuzzz
• 38,000 points
610 views
0 votes
1 answer

What datatype should be used for storing phone numbers in SQL Server 2005?

Does this include: International numbers? Extensions? Other information besides the ...READ MORE

answered Sep 11, 2022 in Database by narikkadan
• 63,600 points
1,664 views
0 votes
1 answer

Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) in sql 2008

Solution Go to Start > Programs > Microsoft SQL Server > Enterprise Manager. Right-click the SQL ...READ MORE

answered Sep 12, 2022 in Database by narikkadan
• 63,600 points
1,094 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP