-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Description
I'm trying to write Unicode strings from R to SQL. Unfortunately, the Unicode characters only seem to work when I load the table back into R, and not when I view the table in SSMS or A different tool.
require(odbc)
require(DBI)
require(dplyr)
con <- DBI::dbConnect(odbc::odbc(),
.connection_string = "DRIVER={ODBC Driver 13 for SQL Server};SERVER=Test; Database=Test; trusted_connection=yes;")
testData <- data_frame(Characters = "❤")
dbWriteTable(con,"TestUnicode",testData,overwrite=TRUE)
result <- dbReadTable(con, "TestUnicode")Successfully yields:
> result$Characters
[1] "❤"However, when I pull that table in SSMS:
SELECT * FROM TestUnicodeI get two different characters:
| Characters |
|---|
| ⤠|
It looks like the column stored in SQL is a varchar rather than nvarchar, and somehow the binary value of the particular heart character ends up being different than what I get when I insert a row from SSMS. Can the unicode characters be stored in a way that they can be used universally and not just in R?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels