On my Windows Server 2019 In my NodeJS script I'm writing to the database using the Prisma library.
The field I'm adding this to is an NVARCHAR(1000)
field. So that should accept this character, right?
The string input comes from fs.readFileSync(customJobPath, 'utf8')
, I'm reading a txt file with the data
I have the following word Gardé
- Now on my local database this is saved correctly
- In my production MSSQL database, it's entered as
Gard�
What I've tried
- I've checked the collation of both the database using
SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation') AS DatabaseCollation;
, and in both cases it's set toSQL_Latin1_General_CP1_CI_AS
- When inserting an
é
character manually and saving (in Tableplus), it is saved correctly in the database.
Does anyone know if there's something I'm missing?
1条答案
按热度按时间7dl7o3gd1#
There's not enough information in the question to be sure, but I suspect you have one (or more) of four issues:
N
prefix for the literal... if you have'Gardé'
in the SQL string instead ofN'Gardé'
. The former is first interpreted as a basicvarchar
value, so the non-ASCII characters are lost. The latter is correctly interpreted as annvarchar
.varchar
instead ofnvarchar
(perhaps implicitly, by failing to explicitly type the parameter). Again, in this situation the value is first processed as avarchar
where the non-ASCII symbols are lost, before saving to thenvarchar
field.readFileSync()
method we needed utf8, it doesn't mean the string variable we assigned the result to was able to correctly receive this result.)