To load R dataframe into SQL

I have an excel file with date columns and am able to load the excel data to R with date format showing as POSIXct.
I am using library("RODBC") to insert records from R to SQL. Here is my code

sqlSave(dbconnection,R2,"R_Month2", append = TRUE,rownames = FALSE)
```R

when executing this code its giving error as,

Error in sqlSave(dbconnection, R2,"R_Month2", append = TRUE,,  : 
  [RODBC] Failed exec in Update
22018 0 [Microsoft][SQL Server Native Client 11.0]Invalid character value for cast specification**

Please suggest,

According to this post

Invalid character value for cast specification comes from the driver when:
1.) It detects a string -> non-string conversion (e.g. string -> time or string -> boardid or string->messageid)
2.) It detects that a character is out of the domain for the conversion (e.g. converting 'bob' to int)

ok, I tried converting the character to as.date but couldnt. Any work around

How would you insert a record with a date field into MSQL manually?

I converted the date field to character and able to insert, now how can I get the dates back in R.
or is there a way to insert date into SQL

How do you insert a date string into MS SQL natively?

SQLSave will do the work

Please Any idea from anyone to append data from R to SQL when date is present,

This topic was automatically closed 21 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.