SQL SERVER 2016 R服务 - SQL Server不存在或访问被拒绝

时间:2016-10-10 23:50:47

标签: sql r database-connection sql-server-2016

我正在尝试学习新功能 - 在SQL Server 2016中使用R,而我正在关注此link作为示例。

我将SQLRUserGroup设置为新的登录名并且能够运行一些R脚本,但data_preprocess_score.sql给出了以下错误消息,它看起来与连接有关。

以下是我试图称之为sproc的内容:

EXEC data_preprocess_score @testlength = 1, @id1value = 2, @id2value = 1,
    @connectionString = 'SERVER=.;DATABASE=Test;Trusted_Connection=true;`'

以下是错误消息:

Msg 39004, Level 16, State 20, Line 1
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 1, Line 1

发生外部脚本错误:

[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Error in doTryCatch(return(expr), name, parentenv, handler) : 
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Calls: source ... tryCatch -> tryCatchList -> tryCatchOne -> doTryCatch -> .Call
In addition: Warning message:
In Ops.factor(tsvalues, value.threshold) : '>' not meaningful for factors

Error in ScaleR.  Check the output for more information.
Error in eval(expr, envir, enclos) : 
Error in ScaleR.  Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted

来自外部脚本的STDOUT消息:

Rows Read: 166, Total Rows Processed: 166Caught exception in file: CxAnalysis.cpp, line: 6488. ThreadID: 14112 Rethrowing.

[Microsoft][ODBC Driver Manager] Connection not open

ODBC Error in SQLDisconnect
Caught exception in file: CxAnalysis.cpp, line: 5682. ThreadID: 14112 Rethrowing.
Caught exception in file: CxAnalysis.cpp, line: 5249. ThreadID: 14112 Rethrowing.

有人可以帮我解决这个错误吗? 谢谢!

2 个答案:

答案 0 :(得分:0)

Driver=SQL Server添加到连接字符串的前面。设置Server=localhost也没有坏处。

EXEC data_preprocess_score @testlength = 1, @id1value = 2, @id2value = 1,
    @connectionString = 'Driver=SQL Server;SERVER=localhost;DATABASE=Test;Trusted_Connection=true;'

答案 1 :(得分:0)

如果能够运行R脚本来获取数据,但在使用rx函数(如rxPredict / rxDataStep)写入数据时会出现以下错误:

  

DBNETLIB; SQL Server不存在或访问被拒绝

然后,您可能遇到了从R脚本到SQL Server的回送连接的问题。请检查环回连接所需的以下配置:

  1. 使用说明here

  2. 启用了对Launchpad帐户的隐含身份验证
  3. 使用说明here

  4. 为服务器启用TCP / IP客户端协议

    特别是在您的情况下,请检查TCP / IP协议配置,因为您提到了SQLRUserGroup的登录已创建。