I’m trying to resize a column down to 64 characters in length:
ALTER TABLE [dbo].[consumption] ALTER COLUMN [resourceGroup] VARCHAR(64) NOT NULL
but I get the following error:
String or binary data would be truncated in table ‘dbo.consumption’, column ‘resourceGroup’. Truncated value: ”.
This doesn’t make sense to me: how can you truncate nothing?
Any help would be appreciated.
Advertisement
Answer
Thanks to comments by @MartinSmith and @DaleK, I think I’ve come to the answer on this one.
The documentation provided with the data source I’m writing to this column stated that it should not be longer than 64 characters. Then, when I tried changing the length of the column, the error message led me to believe that SQL Server was issuing an error over an empty string. According to @MartinSmith, this type of error message is a recent development and so the offending value probably hasn’t been injected into it yet for ALTER TABLE
commands. Moreover, queries against the column reveal that it does contain values longer than 64 characters.
Therefore, this error message should be taken at its meaning and the truncation value ignored.