I am trying to migrate data from Postgres database to SQL server. For this, I am exporting the Postgres data into JSON format, and the idea is to insert the data into my tables (I already have the schema from Postgres database imported into SQL server).
I am playing around with the OPENROWSET function, but there seem to be problems with the encoding. I noticed in the documentation that there is a CODEPAGE option that should solve this problem, but it doesn't do anything in the way I am specifying it.
This is my example query:
SELECT users.*
FROM OPENROWSET (BULK 'path_to_some.json', SINGLE_CLOB, CODEPAGE = '65001') as j
CROSS APPLY OPENJSON(BulkColumn)
WITH(id int,
first_name nvarchar(max),
last_name nvarchar(max),
email nvarchar(max),
accepts_marketing bit,
created_at datetime,
updated_at datetime) AS users
order by id
Does anyone have an idea what am I missing here?