我已經使用R函數編寫了SQL Server存儲過程。所有的工作都沒有Sql Server Management Studio的問題,只有一個例外。在R中調用季節性包的SQL Server存儲過程
我想使用季節性包,但Sql Server Management Studio中的代碼失敗。相同的代碼在R(C:\ Program Files \ Microsoft SQL Server \ MSSQL13.SQLEXPRESS \ R_SERVICES \ bin)中工作得非常好。
Sys.setenv("X13_PATH" = "C:/Program Files/Microsoft SQL Server/MSSQL13.SQLEXPRESS/R_SERVICES/library/x13binary/bin");
require(seasonal);
seasonal::checkX13()
(我在這裏包括了X13_PATH,因爲它是必要的SQL Server R的工作 - 從我的桌面[R運行時,它不是必需的)。
顯示的錯誤信息是:
STDERR message(s) from external script:
Loading required package: seasonal
X-13 installation test:
- X13_PATH correctly specified
- binary executable file found
- command line test run successful
- command line test produced HTML output
Error : seasonal test run failed, with the message:
Error : X-13 has run but produced no data
Error details:
- X13_PATH: C:/Program Files/Microsoft SQL Server/MSSQL13.SQLEXPRESS/R_SERVICES/library/x13binary/bin
- Full binary path: "C:/Program Files/Microsoft SQL Server/MSSQL13.SQLEXPRESS/R_SERVICES/library/x13binary/bin/x13ashtml.exe"
- Platform: x86_64-w64-mingw32
- R-Version: R version 3.2.2 (2015-08-14)
- seasonal-Version: 1.1.0
來自R在sql目錄返回完全相同的代碼運行:
X-13 installation test:
- X13_PATH correctly specified
- binary executable file found
- command line test run successful
- command line test produced HTML output
- seasonal test run successful
Congratulations! 'seasonal' should work fine!
我授予這些文件夾完全控制權限(R,爲R庫文件夾,爲X13二進制文件夾),希望這將解決問題,但它仍然失敗...
任何想法如何解決這個請嗎?
根本原因:通過在sqlserver中執行外部R腳本而創建爲臨時文件的數據文件的名稱非常長。此路徑在由x13ashtml.exe過程讀取的.spc文件中指定,該過程將數據文件名的限制設置爲133. –
創建符號鏈接到ExtensibilityData文件夾 mklink/dc:\ extensibilitydata- <完整實例名稱> 「C:\ Program Files \ Microsoft SQL Server \ MSSQL13.MSSQLSERVER \ MSSQL \ ExtensibilityData」 eg mklink /dc:\extensibilitydata-MSSQL13.MSSQLSERVER「C:\ Program Files \ Microsoft SQL Server \ MSSQL13.MSSQLSERVER \ MSSQL \ ExtensibilityData」 編輯C:\ Program Files \ Microsoft SQL Server \ MSSQL13.MSSQLSERVER \ MSSQL \ Binn \ rlauncher.config, 將WORKING_DIRECTORY設置爲這個新創建的符號鏈接。 例如 WORKING_DIRECTORY = C:\ extensibilitydata-MSSQL13.MSSQLSERVER –
重新啓動Sql Server啓動板服務。在提升的命令提示符下執行:net stop mssqllaunchpad&net start mssqllaunchpad –