2

I am just trying to write codes in R-Script in SQL but I am getting this error. Can anyone please help

execute sp_execute_external_script 
@language = N'R',
@script = N'
 
install.packages("rvest")
library(rvest)
authorshtml <- read_html("https://www.mssqltips.com/sql-server-mssqltips-authors/")
authors <- authorshtml %>% html_nodes("div .large-7") %>% html_nodes("a") %>% html_text() 
OutputDataSet <- data.frame(authors)
 
'
with result sets ((Authors varchar(max)))

but I get this error nd cant seem to figure it out.

Msg 39004, Level 16, State 20, Line 0
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 0
An external script error occurred: 
Error in eval(ei, envir) : object 'N' not found
Calls: source -> withVisible -> eval -> eval

Error in execution.  Check the output for more information.
Error in eval(ei, envir) : 
  Error in execution.  Check the output for more information.
Calls: runScriptFile -> source -> withVisible -> eval -> eval -> .Call
Execution halted
r2evans
  • 141,215
  • 6
  • 77
  • 149
Ted Fam
  • 21
  • 1
  • I think the `N'...'` nomenclature is to protect unicode varchars (https://stackoverflow.com/a/35671587/3358272). You might try without the leading `N` (just `@script = '...'`), though that should be just a troubleshooting step, not a permanent change to your query/process. – r2evans Apr 22 '21 at 21:04
  • I've tried that and didn't seem to make much difference. Now it doesn't seem to recognize the library command as well as the package (RVEST) which has been downloaded – Ted Fam Apr 26 '21 at 15:31

0 Answers0