patternsqlMajor
SQLCMD command is not able to insert accents
Viewed 0 times
insertaccentssqlcmdcommandnotable
Problem
I am trying to run sqlcmd.exe in order to setup a new database from command line. I am using SQL SERVER Express 2012 on Windows 7 64 bits.
Here's the command I use:
And here's a pieceof the sql file creation script:
Well, please check that there are some accents on the words; which is the table's description . The database is created with no problems. 'Collate' is understood by the script, as you can see in the attached screenshot. Despite of this, accents are not properly shown when examining the table.
I'd really appreciate any help. Thank you very much.
[Edit]: Hi all. Changing the SQL file encoding using Notepad++ worked fine! Thank you very much for you help: I learned something interesting with this problem!
Here's the command I use:
SQLCMD -S .\MSSQLSERVER08 -V 17 -E -i %~dp0\aqualogyDB.sql -o %~dp0\databaseCreationLog.logAnd here's a pieceof the sql file creation script:
CREATE DATABASE aqualogy
COLLATE Modern_Spanish_CI_AS
WITH TRUSTWORTHY ON, DB_CHAINING ON;
GO
use aqualogy
GO
CREATE TABLE [dbo].[BaseLayers] (
[Code] nchar(100) NOT NULL ,
[Geometry] nvarchar(MAX) NOT NULL ,
[IsActive] bit NOT NULL DEFAULT ((1))
)
EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Capas de cartografía base de la aplicaicón. Consideramos en Galia Móvil la cartografía(...)'
, @level0type = 'SCHEMA', @level0name = N'dbo'
, @level1type = 'TABLE', @level1name = N'BaseLayers'Well, please check that there are some accents on the words; which is the table's description . The database is created with no problems. 'Collate' is understood by the script, as you can see in the attached screenshot. Despite of this, accents are not properly shown when examining the table.
I'd really appreciate any help. Thank you very much.
[Edit]: Hi all. Changing the SQL file encoding using Notepad++ worked fine! Thank you very much for you help: I learned something interesting with this problem!
Solution
Another option, one which I've just learned, comes from the
sqlcmd documentation. You need to set the codepage for sqlcmd to match that of the file encoding. In the case of UTF-8, the codepage is 65001 so you'd want:SQLCMD -S .\MSSQLSERVER08 -V 17 -E -i %~dp0\aqualogyDB.sql -o %~dp0\databaseCreationLog.log
-f 65001Context
StackExchange Database Administrators Q#40516, answer score: 49
Revisions (0)
No revisions yet.