Automatic transfer data from the sql to R
问题 I get the data from the sql server to perform regression analysis, and then the regression results i return back to another sql table. library("RODBC") library(sqldf) dbHandle <- odbcDriverConnect("driver={SQL Server};server=MYSERVER;database=MYBASE;trusted_connection=true") sql <- "select Dt ,CustomerName ,ItemRelation ,SaleCount ,DocumentNum ,DocumentYear ,IsPromo from dbo.mytable" df <- sqlQuery(dbHandle, sql) reg=lm(SaleCount~IsPromo,data=df) #save to sql table sqlSave(dbHandle, as.data