The (R) code below works on my machine and when executed in R on the database server. I am also pretty sure that the security is set correctly. Unfortunately, when run as SQL script (see below), I get this message:
cannot change working directory
Calls: source -> withVisible -> eval -> eval -> setwd
Btw, I can setwd and read/write directly on the server using:
setwd("X:/somewhere_amazing/xyz")
So I am bit lost, as to what the issue may be? Any feedback would be very much appreciated! Thanks.
EXEC sp_execute_external_script @language = N'R',
@script = N'
df <- data.frame(x = c("a", "b"))
setwd("\\\\bla\\somemore\\another_subfolder\\")
write.csv(df, "test.csv", row.names=F)
'
I also tried:
EXEC sp_execute_external_script @language = N'R',
@script = N'
df <- data.frame(x = c("a", "b"))
write.csv(df, "\\\\bla\\somemore\\another_subfolder\\test.csv", row.names=F)
'