UTF-8 not recognized in SQL batch process through Putty

0

I have an .sql file with a few simple "Insert into" SQL commands that are being inserted into a table called Künstler.

insert into Künstler (name) values ('Mariah Carey');
insert into Künstler (name) values ('Michael Jackson');

However upon executing the file through Putty to run all these commands, each line is met with an error;

During SQL processing it returned:
SQL0007N The following on "insert into K" mark "▒" is invalid.

It seems the German umlaut characters are being transformed into '▒'

I have enabled UTF-8 on Putty and the commands will work if entered manually, but not as a batch. Is there any work around?

For extra information, the language I am using is DB2.

Pejman Poh

Posted 2016-01-14T15:41:07.813

Reputation: 11

This is a very bad idea, to call the column "Künstler". I would consider, simple to rename the colomn. – duDE – 2016-01-14T15:49:00.050

@duDE Yeah I would do the same but unfortunately I don't have a choice in the matter :/ – Pejman Poh – 2016-01-14T15:54:25.087

Answers

0

Running a script in PuTTY is not affected by any of PuTTY's settings. It would only depend upon the encoding (character-set) of the script and your locale settings (as well as the database's encoding—and the way it reads scripts).

When you type on the keyboard using PuTTY, that depends on PuTTY's settings for the keyboard.

Rather than look for a fix in PuTTY, you might be able to set your application code page (mentioned in the DB2 reference) to UTF-8 (page 1208 according to Understanding DB2 Universal Database character conversion). According to Derivation of code page values, that should happen automatically if your locale is set properly.

Thomas Dickey

Posted 2016-01-14T15:41:07.813

Reputation: 6 891

0

Solution turned out to be rather simple. I was writing the script in notepad++ and I had set the file to the wrong encoding. Switching the encoding from the default ANSI to UTF-8 solved the issue.

This can be done through Encoding -> Encode in UTF-8 without BOM.

Pejman Poh

Posted 2016-01-14T15:41:07.813

Reputation: 11