Forum Discussion

SwaTHasSasIN's avatar
SwaTHasSasIN
Occasional Reader
Nov 12, 2025
Solved

“8152 String or binary data would be truncated” error while running select query on a view

I have a complex view (it’s organisational so i cannot paste it here) that joins multiple tables, uses CTEs, performs logical calculations and then provides for multiple columns over which we can select. This view is based on top of multiple master tables and a transactional table. It was performing fine until today morning. But then it started throwing 8152 error. I’m assuming it’s started happening only after certain values got written to the transactional table. The funny thing is, that the view is still executing fine if I remove just one column from the select query. If i include that one column in the select query, it throws 8152 error. I spent my entire day trying to troubleshoot, but couldn’t. Unable to understand how the view is running fine but the including a column in the select query causes it to malfunction. Any insights would be much appreciated. 

  • I was able to resolve it by using convert(nvarchar(max), <attributenames>) wherever possible. Made my query slower, but it’s not throwing error at least. 

    Not sure if this was the right way to resolve though. 

1 Reply

  • SwaTHasSasIN's avatar
    SwaTHasSasIN
    Occasional Reader

    I was able to resolve it by using convert(nvarchar(max), <attributenames>) wherever possible. Made my query slower, but it’s not throwing error at least. 

    Not sure if this was the right way to resolve though. 

Resources