SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


French characters into SQL Server


French characters into SQL Server

Author
Message
schleep
schleep
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1008 Visits: 1326
Hi all,

I use Powershell to deploy DB scripts. In one script file, I have French accented characters.
When I call Invoke-sqlcmd and pass the script to the -inputfile, the French characters get mangled.

In the bad old days, the workaround was to save the files as unicode, and sqlcmd would handle them OK.
How do I go about this in this brave new world?

Thanks!

Paul



Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14859 Visits: 14396
Cmdlet Out-File has a -Encoding option.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
schleep
schleep
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1008 Visits: 1326
Forgive me, maybe it's too early on Monday, but I'm not sure how that helps me?

The source file is fine, it's getting the accents into SQL Server that's problematic.



Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14859 Visits: 14396
Sorry I misunderstood the scenario. Try changing the input file encoding from UTF-16LE (what Microsoft calls "Unicode") to UTF-32 and see if passing that file works. It's a workaround but I think you need it for Invoke-SqlCmd to get the job done. It's an open issue with the file handling in the Cmdlet.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
schleep
schleep
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1008 Visits: 1326
I was able to Set-Content of the source files to Unicode, and they appeared OK when opened in SSMS.
I had a test version working fine; but when those files were passed to Invoke-Sqlcmd, the accented chars were again mangled.

So I've reverted to using sqlcmd.

Thanks for taking the time to respond.

P



Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14859 Visits: 14396
You're welcome. Happy you got it sorted.

As I said though, "Unicode" = UTF-16LE. I was saying to try the input file in UTF-32 format. Something like this would have created it:

"Hello world!" | Out-File -FilePath C:\InputFile.txt -Encoding UTF32


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
AlreadyPicked
AlreadyPicked
Mr or Mrs. 500
Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)

Group: General Forum Members
Points: 512 Visits: 329
Using Powershell 3, I had the same problem but ended up doing this:


$UnicodeFileName = $ScriptPath + "\UnicodeFileContent.sql"

$FileContent = Get-Content $FileName

$FileContent | Out-File -FilePath $UnicodeFileName -Encoding Unicode

Invoke-Sqlcmd -ServerInstance $SqlServer -Database $Database -InputFile $UnicodeFileName -AbortOnError -Verbose



___________________________________
I love you but you're standing on my foot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search