0
votes

I am trying to export a SQL Server database into CSV files. For that, I am using a powershell script.

As you can see, in the database I have some special characters (Danish language).

capture of my database table

But in the exported files, those characters are replaced with a ? as you can see below :

csv output file

For information, in my powershell script, here is the line exporting the file :

$DataSet.Tables[0] | Export-Csv $extractFile -NoTypeInformation -Encoding "ISO-8859-15"

Can anyone help? Thanks!

EDIT :

@JamesQMurphy here is the code

dataset

1
Is -Encoding "ISO-8859-15" a valid encoding parameter? I thought the list was Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM? Have you tried -Encoding UTF7 for example? - Shaneis
Yes, and it didn't work :( - imanebz
Can you show the code that populates your $DataSet? - JamesQMurphy
I edited my post. You can now see the code. @JamesQMurphy - imanebz

1 Answers

1
votes

Tested this and the correct encoding for me was BigEndianUnicode

Change your encoding to this:

$DataSet.Tables[0] | Export-Csv $extractFile -NoTypeInformation -Encoding BigEndianUnicode