I’m trying to use DB writer to write table into sql server database. Some of my columns are in string with Chinese character, DB writing by mapping string to varchar is ok, but the Chinese charater is displayed like ??? in varchar format. I tried to map string to nvarchar, the DB writer reported “String or binary data would be truncated” error.
In the past when I was using the legacy database writer node to write string containing Chinese character in nvarchar format, everything is good.
So the question is:
Is there a way to set the length of the nvarchar format? I searched the error code, looks like it is caused by inserting data into a string column while the data size is more than the column size.
Probably above is not the real cause? Any idea on how to solve this?
I think you have to specify the length of your nvarchars by specifying the type like this: nvarchar(max), where max is the maximum length of your strings. If max is not given, it defaults to 1. Please have a look at this website for more info:
If you mostly want to write NVARCHAR you can also change the default output type mapping in the Microsoft SQL Server Connector node. All nodes that are connected to the connector node inherit its type mapping settings.
could you please help to understand what the problem might be. Attached you can find the workflow I used for testing. I created one table with database type varchar(max) which didn’t work since it returned as expected ??? for the Chinese characters.
However when I created a table with nvarchar(max) I was able to write and read my example text. The workflow also contains a DB Query Reader that executes a statement which gets detailed information about the table structure from the database.
Can you please check with your database if the example workflow runs as expected or adapt your workflow accordingly and also double check using the DB Query Reader node that the column in your database table has the right type as shown below.