SQLTeam.com | Weblogs | Forums

Json import and unicode encoding?



I am import json data into a MSSQL database, running on linux.
In the json file, the special characters is okay, but when importing them,the special characters gets messed up.

DECLARE @thesql nvarchar(1000)
SET @thesql = '
SELECT BulkColumn,''filenamecrap'', GETDATE()
FROM OPENROWSET(BULK ''/var/www/html/dbs/cronfiles/files/thefile.json'', SINGLE_CLOB) as x';

I have tryed changing the SINGLE_CLOB to SINGLE_NCLOB, but that just give me this error:
"SINGLE_NCLOB requires a UNICODE (widechar) input file. The file specified is not Unicode."
When opening the json file in notepadd++, it says the encoding is UTF-8

Anybody that can help me get this fixed? The json file is downloaded trough php and curl.

Please enlight me - unicode and encoding stuff always confuses me!:slight_smile: