Skip to content
Prev 65941 / 398506 Next

RODBC, sqlSave and sqlAppend

I use RODBC all day every day and while I am pretty happy with it, I
was never able to make a table separately and append to it using
sqlSave.  Nevertheless, maybe my observations will help.

I always let sqlSave make the table for me.  Make sure the table
doesn't exist and it will make it.  I never use sqlAppend, I use
sqlSave(..., append=TRUE).  Also, how do you know you are not getting
an error.  Try 'go <- sqlSave(...)' and then type go and if it returns
'character(0)' then you have no error, otherwise you will see an
extremely brief hint of what went wrong.  Finally, I always have my
database open when I sqlSave and that is never a problem, so you don't
need to close MS access AFAIK.  Its probably easier to use sqlQuery
right after sqlSave to verify that it worked.

Once sqlSave works, then you can use standard SQL statements to alter
the table and alter to columns to make the datatypes whatever you want
and then use 'insert into' statements to move the data when you want. 
So basically, because I save to a temporary table, alter the columns
to change the datatypes, and then copy that to my final table.  Sounds
like a lot of work, but it can be automated once you write the command
in R.

Maybe someone will provide you with a better answer, but this might
get you started.

Thanks,

Roger


On Tue, 15 Mar 2005 15:19:26 -0000, Matthew W Nash
<spjgmwn at iop.kcl.ac.uk> wrote: