且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试在 power bi 中实现 r 脚本以更新 SQL Server 数据库

更新时间:2023-01-31 21:10:10

尝试将源查询中的所有 CHAR 和/或 VARCHAR 数据类型转换为 NCHARNVARCHAR 分别.如果您的源数据包含任何 ASCII 字符代码为 128 或以上(尤其是 192 或以上)的字符,您可能会遇到字节码版本不匹配"错误.

这里有一些额外的阅读:sp_execute_external_script 和字节码版本不匹配

I'm trying to implement a r script within power bi to update a SQL Server database. I keep running into this problem... anyone know how I can resolve the error?

library(RODBC)
outputframe=data.frame(dataset)
DBHANDLE<-odbcDriverConnect('driver={SQL Server};server=____;database=___;trusted_connection=true')

TBLExist="sbs.Iterations" %in% sqlTables(DBHANDLE)$TABLE_NAME
if (!TBLExist)
sqlSave(DBHANDLE, data.frame(dataset), tablename = "sbs.Iterations",rownames=FALSE, append = FALSE)

DataSource.Error: ADO.NET: R script error. During startup - Warning message: In setJsonDatabasePath(system.file("extdata/capabilities.json", : bytecode version mismatch; using eval Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, numerals = numerals, : invalid input '[Adhoc] [C2R]:When user clicks on 🙂(Provide feedback) from Main UI, User is not able to see submit button.' in 'utf8towcs' Calls: read.csv -> read.table -> type.convert Execution halted Details: DataSourceKind=R DataSourcePath=R Message=R script error. During startup - Warning message: In setJsonDatabasePath(system.file("extdata/capabilities.json", : bytecode version mismatch; using eval Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, numerals = numerals, : invalid input '[Adhoc] [C2R]:When user clicks on 🙂(Provide feedback) from Main UI, User is not able to see submit button.' in 'utf8towcs' Calls: read.csv -> read.table -> type.convert Execution halted ErrorCode=-2147467259 ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException

Try casting all of the CHAR and/or VARCHAR data types in your source query to NCHAR and NVARCHAR respectively. If your source data contains any characters with ASCII character codes of 128 or above (and in particular, 192 or above), you may encounter the "bytecode version mismatch" error.

Some additional reading here: sp_execute_external_script and Bytecode Version Mismatch