1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
library(RODBC) # Connect to the database while mentioning database name explicitly. channel <- odbcDriverConnect("driver=SQL Server;server=ServerName;database=DatabaseName") # Change all Columns to Strings to avoid errors for (col.name in colnames(Students)) { Students[,col.name] <- as.character(Students[,col.name]) } # Drop the table sqlDrop(channel, 'idin.Students2') # Write the table into the database sqlSave(channel, Students, tablename = 'idin.Students2', append = FALSE, rownames = FALSE) close(channel) |