[R-sig-DB] Problems with sqlSave

Grey Moran grey@mor@n @end|ng |rom gm@||@com
Wed Nov 12 00:06:24 CET 2008


Hello,
I am trying to load data into SQL Server as follows (example
simplified for discussion purposes). The returned error complains of a
non existent table, which I can nevertheless "see":

>channel <- odbcConnect("MktRisk")
>createTable.q <- "CREATE TABLE dbo.Arrests (State CHAR(20) NOT NULL, MURDER DECIMAL(6,3) NOT NULL, ASSAULT INTEGER NOT NULL, URBANPOP INTEGER NOT NULL, RAPE DECIMAL(6,3));"
>sqlQuery(channel, createTable.q);
character(0)
> sqlTables(channel)
  TABLE_CAT TABLE_SCHEM             TABLE_NAME   TABLE_TYPE REMARKS
.................
19   MktRisk         dbo               sysusers SYSTEM TABLE    <NA>
20   MktRisk         dbo                Arrests        TABLE    <NA>
..................

> sqlSave(channel, dat=USArrests, tablename=Arrests, rownames = "state", addPK=TRUE)
Error in sqlSave(channel, dat = USArrests, tablename = Arrests,
rownames = "state",  :   object "Arrests" not found

in the real case (more complex and hard to show here), I get this error:
Error in sqlSave(channel, dat = the.bridge.df, tablename = someTable,
:   unable to append to table 'US15Aug2008BridgeTable'

As far as I can tell, the tables I create are of the appropriate kind
- any ideas what might be the problem?

Thank you,

Grey




More information about the R-sig-DB mailing list