SQL Server procedure that did not complete when it executed from R

穿精又带淫゛_ 提交于 2019-12-24 20:06:02

问题


When I ran a procedure from R, it stops in the middle of the execution. But if I ran it directly from SQL Server, it completes the execution.

Here is the code (there is not a lot to show):

connection<-odbcDriverConnect("SERVER=server_name;DRIVER={SQL Server};DATABASE=DB;UID=RUser;PWD=****")
stringEXEC<-"EXEC [dbo].[LongProcedure]"
data<-sqlQuery(channel = connection,query = stringEXEC,errors = TRUE)

Some remarks:

  • the procedure is calling for 12 another procedures. and each of the 12 creating a specific table (it's very long query to print it here in the question)

And there is no error.

Why is this happening?


回答1:


I ran into a similar issue. Currently, you can only execute SELECT statement from R, not stored procedures.

If you prefer working in R-Studio, I suggest executing the results of your stored procedure into a table in SQL Server first, then using that table in R. You'll still get the benefit of scalability with that compute context.

Passing T-SQL select statement to sp_execute_external_script



来源:https://stackoverflow.com/questions/47249513/sql-server-procedure-that-did-not-complete-when-it-executed-from-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!