Skip to content

Badly encoded characters output when querying sys.extended_properties #1740

Description

@giswa

Hi guys,

I'm getting badly encoded chars specifically when I use the sys.extended_properties table.

I get german: f�r instead of für, Integrit�t for Integrität
Using this code as a test :

const sql = require('mssql');
const fs = require("node:fs");

(async () => {
    try {
        // make sure that any items are correctly URL encoded in the connection string
        await sql.connect('...')
        const result = await sql.query`SELECT top 10 * FROM sys.extended_properties`
        fs.writeFileSync('extended-properties.json', JSON.stringify(result , null, 2));
    } catch (err) {
        console.error(err);
    }
})()

On all other user tables, there are no encoding problems
My DB collation is Latin1_General_CI_AI

Any idea ?

Activity

dhensby commented on May 6, 2025

@dhensby
Collaborator
  • What version of the library is this relating to?
  • What debugging steps have you taken so far?
  • Can you fetch the data encoded correctly via another means?
  • How did you put the data in? Do you have minimal reproduction example?

giswa commented on May 7, 2025

@giswa
Author

I've tested using the simple code above. It's using mssql version 11.0.1

Changing the driver to msnodesqlv8 resolves the problem

const sql = require('mssql/msnodesqlv8');

To reproduce I'm inserting into extended_properties using the MS stored procedure :
https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addextendedproperty-transact-sql?view=sql-server-ver16

USE AdventureWorks2022;
GO

EXEC sys.sp_addextendedproperty @name = N'MS_Description',
    @value = N'Stadtführungen auf deutsch.',
    @level0type = 'SCHEMA', @level0name = N'Person',
    @level1type = 'TABLE', @level1name = N'Address';
GO

dhensby commented on May 7, 2025

@dhensby
Collaborator

Changing the driver to msnodesqlv8 resolves the problem

that indicates that this may be a problem in the tedious driver, then. If you use just the driver and not the mssql lib, do you have the same problem?

giswa commented on May 7, 2025

@giswa
Author

Oh… didn’t know I could do that.
Can you give me a hint on how I can try this ?

dhensby commented on May 7, 2025

@dhensby
Collaborator

Just using the underlying library directly: https://github.com/tediousjs/tedious

giswa commented on May 7, 2025

@giswa
Author

So yes, I can reproduce using the tedious library only (v18.6.1)

// using system extended_properties view
const query = 'SELECT value FROM sys.extended_properties WHERE major_id= 50099219 AND minor_id = 6' ;
// ouputs  Stadtf�hrungen auf deutsch."

// using any normal user table 
const query= 'SELECT plainText FROM Notes' ;
// ouputs "Stadtführungen auf deutsch."

Should I transfer this issue somewhere else ?

dhensby commented on May 8, 2025

@dhensby
Collaborator

Hmm - I tried transferring the issue to tedious but it didn't work. Would you mind opening a new one there and we can close this as an upstream bug.

added
upstreamRoot cause is in an upstream dependency
on Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamRoot cause is in an upstream dependency

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions