Exporting content of a variable into a SQL table

Hi, I am new to R and struggling. The code below exports the PowerBI audit and displays it within R. How would I export that to a SQL table? I have tried and tried and just not getting anywhere. Thank you...


#change the first number to the number of days you want to go back
1..1 |

foreach {

$Date = (((Get-Date).Date).AddDays(-$_))
$StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)
$EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)

$activities = Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate

#Use to display output
Write-Output $activities

Hi, if you are using the DBI package to manage your DB connection, then using dbWriteTable() should work. If you wish to add new records to your table, pass the append = TRUE as an argument. Here is the reference link: Copy data frames to database tables — dbWriteTable • DBI

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.