Bad string encoding between BE and LE

Jaroslav Zeman 1 Reputation point
2022-09-18T20:44:05.537+00:00

Hi

I have two sql servers: MariaDB, MS SQL, both server are connected over ODBC, (engine connect, linked server). But if I run query in MariaDB over engine connect as remote command, strings are reverse coded in BE a LE on servers. Advise how to ensure that the data is converted to the same format in both systems during exec command?

Example:
CREATE TABLE ExternCommand1 (
cmd VARCHAR(255) CHARACTER SET 'utf8' NOT NULL flag=0 ,
number INT flag=1,
message VARCHAR(255) flag=2)
ENGINE=connect
TABLE_TYPE=odbc
CONNECTION='DSN=MSSQL;UID=111;PWD=1111'
CHARSET = utf8
BLOCK_SIZE = 1
OPTION_LIST='Execsrc=1';

SELECT* FROM `ExternCommand1` WHERE`cmd` = CAST("INSERT INTO [DTB_INTERCHANGE].[dbo].[TestA] (ID, Tx) SELECT 15, N'ßÁȵ$€Ł'" AS VARCHAR(255) CHARACTER SET utf8);  

But in table in column Tx is: ßÃȵ$€Å

Thank

Jaroslav

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
38,563 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 109.8K Reputation points MVP
    2022-09-18T21:28:39.793+00:00

    This is an SQL Server forum, and I cannot answer questions related MariaDB.

    But I note that you say CHARSET = utf8, but you the command you send to SQL Server has an nvarchar literal, so that is UTF-16LE. I would suspect, though, that data has been demolished already when it reaches SQL Server. You can use Profiler to see what SQL Server receives.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.