Question

I'm working with an existing SQL Server 2000 database, which held a field "Rev1". This field was originally designed as a varchar(2). Recently, we've moved to a new ERP system, and to comply they need to have 5 available characters to store. Simple enough problem, so I entered the table's design, and increased the size. I observed the following error:

String or binary data would be truncated. The statement has been terminated

Strange, I thought maybe the information is being encoded in an unexpected way causing the length to exceed the column limits. So I increased the value significantly, and experimented with changing the field to nvarchar. All changes seem to continue throwing the same error on updates and inserts with values longer than two characters. Am I not increasing the column width in a fashion I'd expect, or is there a chance it could silently fail and cause these unexpected results?

Simplified create:

CREATE TABLE [dbo].[Drawings](
[ID] [int] IDENTITY(1,1) NOT NULL,
[...]
[Rev1] [nvarchar](50) NULL,
[...]
CONSTRAINT [PK_Drawings] PRIMARY KEY CLUSTERED 
(
[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,    
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

The following query:

UPDATE Drawings SET Rev1 = '12345' WHERE ID = 12345

Will fail and show the error message along with new inserts. However the queries will succeed if I stay within the original column's width of two characters. Is there something more I can do to ensure the column size has indeed grown as I'd expect?

Was it helpful?

Solution

Sounds like there may be a trigger that is also doing something with this data. Check to see if there are any triggers on the table that might be taking the data from that column and updating/inserting it somewhere else. If so, the column that the trigger is manipulating with also need to be updated with the new data type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top