Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

R Script to Update SQL Server Database

Hi all, 

 

I need to update a database table using a table from Power Query. I know you can export the PowerQuery table as a csv using R, but I need to automate this process directly from power query. 

 

I was able to create the R code to update the database from R Studio

con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "XXX\\SQLEXPRESS",
Database = "Test",
Trusted_Connection = "True")

dbWriteTable(con, "test_table", test_table)
dbDisconnect(con)

When I use this code in Power Query as an R script (using "dataset" as data), it gives me the following error:

DataSource.Error: ADO.NET: R script error.
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 0.2.0 is already loaded, but >= 0.4.5 is required
Calls: <Anonymous> ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Details:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'rlang' 0.2.0 is already loaded, but >= 0.4.5 is required
Calls: <Anonymous> ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException

 

Any help is appreciated! Thank you

1 REPLY 1
lbendlin
Super User
Super User

Fix this issue:

 

namespace 'rlang' 0.2.0 is already loaded, but >= 0.4.5 is required

 

Small side comment: Neither R nor Power Query are replacements for SSIS...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors