I'm using this code:
library(RODBC)
sql3 <- "SELECT TOP 10 Address AS Addr
FROM dbo.Address
Where CountryCode = 'RU'"
con <- odbcDriverConnect('driver={SQL SERVER};server=servername;database=databasename;trusted_connection=true')
df <- as.data.frame(sqlQuery(con,sql3),stringsASFactors=FALSE)
print(df)
Which produces the following results:
> print(df)
Addr
1 115573, ??????, ???????? ?-?, ?.22?
2 107113 ??????, ????? ???????????, ??? 26
3 142200 ??, ?.????????, ??????????? ?., ?. 1
4 614022 ?????, ?????????????? ?????, ??. ????, 37?
5 109453 ?. ?????? ????????????? ????????, ?. 19, ???. 2
6 129282 ??????, ??. ???????, ?.13-?
7 603000 ?????? ????????, ??????? ????????, 2
8 103164 ??????, ????? ??????? ???????????, ??? 26
9 197341, ?????-?????????, ??-? ???????????, ?.19, ????.2
10 429950, ?????????? ???????, ?. ??????????????, ??. ??????????, 42?
The results should be a list of Russian addresses.
As you can maybe see, all 'regular' characters are getting imported fine (e.g. numbers), but the Russian characters aren't making it. I'm guessing I somehow need to set the character encoding before it reaches the dataframe, but I'm not sure how to do that. Also to clarify, the correct address characters appear when the data is queried from SSMS.
Any pointers would be appreciated, thanks.