Page 1 of 1

SQL characterset

Posted: Wed Aug 28, 2019 12:39 pm
by Rukbunker
Hey Oleg,

I have a database set loop where the results are being saved to a TXT file. Works all fine. However, some output is:
"9038926B ?????????? ?? ??????? item name"
And it should be this:
9038926B Инструкция по монтажу item name
The data in the database is correctly saved (with the Russian text), so for sure, this is a characater set issue. In my SQL connection string, I've played a lot of with

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={SQLCat};Data Source={SQLSERVER};Charset=ANSI;
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={SQLCat};Data Source={SQLSERVER};Charset=UTF8;
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={SQLCat};Data Source={SQLSERVER};Charset=UTF-8;

and all other types, but the outcome is still with the "?" signs.
Also adding
SELECT * FROM [{SQLCat}].[Dev].[ServiceAppView] WHERE FileId = 24345
CONVERT TO CHARACTER SET utf8
for example didn't help.

Any suggestions?

Re: SQL characterset

Posted: Thu Aug 29, 2019 12:48 pm
by Oleg
It seems the database code page and system code page do not match.
Are you sure that your database has UTF-8 format?

Re: SQL characterset

Posted: Thu Aug 29, 2019 2:34 pm
by Rukbunker
Can this be something?
Charset
Charset
Capture.PNG (12.09 KiB) Viewed 9455 times
I've tried
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={SQLCat};Data Source={SQLSERVER};Charset=Latin1;
but the result is the same.

Re: SQL characterset

Posted: Thu Aug 29, 2019 3:04 pm
by Oleg
Your database must have Cyrillic charset (windows-1251) if information contains cyrillic symbols.
Otherwise you will get ??? instead of non-latin symbols

Another way
You have to design your database with UTF-8 charset if you want to save any non-ASCII symbols

For example MySQL database creates new database with UTF8 character set by default. You can save in such database any available symbols without problem

Re: SQL characterset

Posted: Thu Aug 29, 2019 3:20 pm
by Rukbunker
Allright. Thanks for the info. I will convert it.

Re: SQL characterset

Posted: Fri Aug 30, 2019 1:42 pm
by Rukbunker
For what is worth, I did it another way.

I did not get permission to convert the database, the risk was too high. Which I can understand! :D

Although I didn't prefer the method, I've used Excel and connected it to the database (just a SQL query) the export the requested data. I deleted the Dataset Loop function in the task. I have to say: it works fine, fast and it has the cyrillic characters (even Chinese).

The task is now even smaller regarding the amount of steps and it's faster.