microsoft/mssql-scripter

Dump breaks umlauts in data

peterhirn opened this issue · 0 comments

Probably related to #113

CREATE TABLE [dbo].[foo] (
    [id] INT NOT NULL IDENTITY(1,1),
    [value] NVARCHAR(256) NOT NULL,
);

INSERT INTO [dbo].[foo] (value) VALUES (N'Hello Wörld');
mssql-scripter -S localhost -d test -U sa --data-only  > ./backup.sql

The resulting file is utf-8 encoded, but the sql values are broken.

ö is converted to 0xE2 0x94 0x9C 0xE2 0x95 0xA2

USE [test]
GO
SET IDENTITY_INSERT [dbo].[foo] ON 

INSERT [dbo].[foo] ([id], [value]) VALUES (1, N'Hello W├╢rld')
SET IDENTITY_INSERT [dbo].[foo] OFF

Subsequent restores of the backup create garbage values, eg. after the first restore Hello Wörld. If this value is then dumped and restored again, it will start to grow fast. eg. second restore Hello W├╢rld.

Update / Workaround

This issue might be limited to running mssql-scripter in powershell. Replacing the output redirect > with -f avoids the problem.

mssql-scripter -S localhost -d test -U sa --data-only -f ./backup.sql
USE [test]
GO
SET IDENTITY_INSERT [dbo].[foo] ON 

INSERT [dbo].[foo] ([id], [value]) VALUES (1, N'Hello Wörld')
SET IDENTITY_INSERT [dbo].[foo] OFF