运行R-Script从SQL Server上的GoogleSheets获取数据

时间:2017-01-18 22:24:44

标签: sql sql-server r tsql

此代码在Visual Studio上正常工作

OutputDataSet <- read.csv(file = "https://docs.google.com/spreadsheets/d/128qCX1YtvsHr4hERruFx6Ykn72qRkpRGH5brFULl7SY/pub?gid=0&single=true&output=csv", header = TRUE, sep = ",", encoding = "UTF-8", stringsAsFactors = FALSE)
OutputDataSet

我尝试使用T-SQL发送此查询

DECLARE @GoogleSheetURL nvarchar(500) = 
'OutputDataSet <- read.csv(file = "https://docs.google.com/spreadsheets/d/128qCX1YtvsHr4hERruFx6Ykn72qRkpRGH5brFULl7SY/pub?gid=0&single=true&output=csv", header = TRUE, sep = ",", encoding = "UTF-8", stringsAsFactors = FALSE)'

EXEC sp_execute_external_script  
  @language =N'R',    
  @script = @GoogleSheetURL,      
  @input_data_1 = N'   ;'    
  WITH RESULT SETS (([Дата] date,[Отдел] nvarchar(20),[Продукт] nvarchar(20),[Продавец] nvarchar(20),[Выставлено_шт] int,[Оплачено_шт] int,[Выставлено] int,[Оплачено] int ));    
go

如何从GoogleSheet将数据导入SQL Server?

ErrorScreen enter image description here

VSScreen enter image description here

1 个答案:

答案 0 :(得分:0)

这是答案.. Windows防火墙中有两个规则 AnswerScreen