Git Product home page Git Product logo

Comments (6)

erikdarlingdata avatar erikdarlingdata commented on June 2, 2024

@gflpcantor31 thanks for reporting this. It didn't come up in any of my testing.

It's sort of an unfortunate state of things with dynamic SQL where at different times in different places string concatenation sometimes implicitly converts to lower byte lengths, causing these truncation errors. There's no great workaround for it other than to add a convert to nvarchar max around every string fragment, which is pretty tedious.

In the meantime, if you find which concatenation point in the dynamic SQL causes this, please let me know.

from darlingdata.

erikdarlingdata avatar erikdarlingdata commented on June 2, 2024

@gflpcantor31 can you try the version in the dev branch and let me know if that resolves the error for you?

from darlingdata.

gflpcantor31 avatar gflpcantor31 commented on June 2, 2024

Hello @erikdarlingdata
I've just tested the latest version, I'm sorry, but the error still occurs identically.

from darlingdata.

gflpcantor31 avatar gflpcantor31 commented on June 2, 2024

Hello @erikdarlingdata

To correct the error, I had to make the following two types of changes:
1 - Because of data type precedence (1) , I added the following:

@table_sql =  CAST(N'' AS nvarchar(max)) + 
.... 
....

2 - Again because of data type precedence and doubts about the data types returned by CASE expressions (?), as a precaution I applied a CAST to CASE expressions like this:

CAST ( CASE 
               WHEN …. 
               WHEN … 
               ELSE …. END  AS nvarchar(max)) 

(1) Data type precedence https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-type-precedence-transact-sql?view=sql-server-ver16
(2)
sp_HumanEvents__#273_gflpCantor31.zip
Maybe I've missed a few, but the only type 1/ change I made didn't resolve the error. That's why, to remove any doubts, I applied type 2/ modifications

Attached you'll find the script sp_HumanEvents__#273_gflpCantor31.zip where I've applied these modifications. With these modifications, I no longer reproduce the error. I'll leave it up to you to check and validate these modifications.

from darlingdata.

erikdarlingdata avatar erikdarlingdata commented on June 2, 2024

@gflpcantor31 If you open a proper pull request with these changes, I'm happy to take a look. It's a bit much to ask me to scroll through 3000 lines looking for your changes and then copying them over into my local file. Thanks!

from darlingdata.

gflpcantor31 avatar gflpcantor31 commented on June 2, 2024

Bonjour @erikdarlingdata
As desired, I've opened a pull request incorporating the changes.
I went back to your last CONVERT modifications (nvarchar(max), ..) and replaced them with a CAST, but only on the CASE expressions that caused the problem.
I've run a few tests. As far as I'm concerned, everything's OK and I don't see the error anymore.
I hope I haven't forgotten anything. I'm not very familiar with Git and Github procedures :)

from darlingdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.