Code Monkey home page Code Monkey logo

Comments (6)

rossipedia avatar rossipedia commented on August 22, 2024

I use sql.NVarChar('max') without issue

from node-mssql.

patriksimek avatar patriksimek commented on August 22, 2024

According to SQL server error messages, MAX length is not supported in prepared statements.

The size (65535) given to the type 'varchar' exceeds the maximum allowed for any data type (8000).
The size (65535) given to the type 'nvarchar' exceeds the maximum allowed for any data type (8000).
The size (65535) given to the type 'varbinary' exceeds the maximum allowed for any data type (8000).

@rossipedia, you should not use sql.NVarChar('max'), it only create NVARCHAR(4000), you should use sql.NVarChar(sql.MAX).

from node-mssql.

patriksimek avatar patriksimek commented on August 22, 2024

My mistake, it was a bug in type declaration. It's fixed now.

from node-mssql.

rossipedia avatar rossipedia commented on August 22, 2024

@patriksimek thanks for the tip! we've since moved to matching parameter types to the columns, but that's good to know for future reference

from node-mssql.

Shadowblazen avatar Shadowblazen commented on August 22, 2024

Not sure if it's this exact bug, but I'm having a problem related to this - using SQL Server 2012 and node-mssql 1.3.0. I'm trying to pass empty string to a prepared statement using sql.NVarChar(sql.MAX) and it fails on execute()

Expected result: [ { MyString: '' } ]
Actual result: execute() failed

Problem only seems occur with the magical combination of sql.MAX and str === ''. As long as there is at least 1 character in the string, or if I use sql.NVarChar(4000) it works as expected.

var ps = new sql.PreparedStatement(connection);

ps.input('str', sql.NVarChar(sql.MAX));

ps.prepare('SELECT @str AS MyString', function (err) {
    if (err) {
        console.log('prepare() failed');
    }

    ps.execute({
        str: ''
    }, function (err, recordset) {
        if (err) {
            console.log('execute() failed');
        }

        console.dir(recordset);
    });
});

from node-mssql.

patriksimek avatar patriksimek commented on August 22, 2024

Thanks for the report, it's fixed and will be part of the 2.0 release.

from node-mssql.

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.