I haven't been able to figure that one out either, but I have a work
around. Lets say I have a table named roger_return that has a column named
datadate that is a smalldatetime. I can't get sqlSave to save to that
table, so I just save it to a new table, say roger_return2. Then I alter
the column and copy the data from that table into the original one. It
sounds like more work, but once you have the code you just re-use it. Here
are the lines that do what I mentioned:
go <- sqlQuery(x, "alter table roger_return2 alter column datadate
smalldatetime NOT NULL")
go <- sqlQuery(x, "insert into roger_return select * from
roger_return2")
HTH,
Roger
On 1/23/06, r user <ruser2006@yahoo.com> wrote:>
> I am running R 2.1.1 in a Windows XP environment.
>
> I wish to use the sqlSave command to export a
> dataframe into Microsoft SQL.
>
> My dataframe is called temp and has 2 "columns",
> "monthenddate" and "value".
>
> Monthenddate is in 'POSIXct', format. (i.e. 'POSIXct',
> format: chr "1984-01-31" "1984-01-31"
"1984-01-31"
> "1984-01-31" ...).
>
> How can I export this dataframe into SQL and have the
> format in SQL by one of the "standard" SQL date
> formats?
>
> I am using the following r code:
>
> db <- odbcConnect("testserver")
> sqlSave(db, temp)
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
[[alternative HTML version deleted]]