BPM, Workflow, and Case

 View Only

Unicode support with OOTB System Data SQL services

  • 1.  Unicode support with OOTB System Data SQL services

    Posted 4 days ago

    We need to support saving unicode characters entered in a coach to a MS SQL Server database and we use the OOTB System Data toolkit SQL services, specifically SQL Execute Multiple Statements (SQLResult).

    The column we have defined is an NVARCHAR type, but the BAW SQL services do not appear to support the NVARCHAR datatype as a SQLParameter.  When inserting the data using a parameterized query and specifying VARCHAR as the parameter type (since that is all the BAW SQL services support), it comes in looking like this:

    SQL:

    CREATE TABLE TestUnicode (Test1 NVARCHAR(100), Test2 NVARCHAR(100))

    BAW SQL:

    tw.local.sqlStatement[0].sql = "INSERT INTO TestUnicode (Test1, Test2) VALUES (?, ?)";
    tw.local.sqlStatement[0].parameters[0] = {value: "test1", type: "VARCHAR", mode: "IN"};
    tw.local.sqlStatement[0].parameters[1] = {value: "المهم الاعتناء بالمريض، وأن", type: "VARCHAR", mode: "IN"};

    If I run the following SQL in the SQL Server Management Studio, it works fine proving the column type is correct and can handle the unicode characters:

    SQL:

    INSERT INTO TestUnicode (Test1, Test2) VALUES ('test2', N'المهم الاعتناء بالمريض، وأن')

    Obviously, the goal would be to used parameterized queries, but I don't think it's possible to support the N'value' syntax using a parameterized query and BAW doesn't support the NVARCHAR datatype.  As a result of these limitations, the solution I've gone with for now is to not parameterize columns that need to support unicode, so it looks like this:

    BAW SQL:

    tw.local.sqlStatement[0].sql = "INSERT INTO TestUnicode (Test1, Test2) VALUES (?, N'المهم الاعتناء بالمريض، وأن'))";
    tw.local.sqlStatement[0].parameters[0] = {value: "test1", type: "VARCHAR", mode: "IN"};

    Before settling on this approach, I wanted to check with the community: has anyone successfully inserted unicode data into a SQL Server database using parameterized queries (SQLParameter) with BAW OOTB SQL services?  Thanks in advance -Don



    ------------------------------
    Don Williams
    ------------------------------