[R] RODBC: sqlSave leave primary key and other columns null

Douglas.Reich at bnymellon.com Douglas.Reich at bnymellon.com
Thu May 20 19:25:04 CEST 2010

I have an existing table, and I am trying to use sqlSave to append 
additional rows to this database. I omit the primary key, which is a 
uniqueidentifier type (MS SQL), so that the database can populate that 
field. However, I get the following error:

>     sqlSave( ch, result, tablename=thetablename, append=TRUE, 
rownames=FALSE, colnames=FALSE )
Error in odbcUpdate(channel, query, mydata, coldata[m, ], test = test,  : 
  missing columns in 'data'

Enter a frame number, or 0 to exit 

1: sqlSave(ch, result, tablename = "CreditLadderData", append = TRUE, 
2: sqlwrite(channel, tablename, dat, verbose = verbose, fast = fast, test 
= te
3: odbcUpdate(channel, query, mydata, coldata[m, ], test = test, verbose = 

Selection: 0

When I explore a little, I see that odbcUpdate is automatically looking 
for ALL the columns in the table, even though some allow nulls.

I also tried putting NAs for those values I wanted to leave as NULL, I 
just get the following error:

Error in sqlSave(ch, result, tablename = "CreditLadderData", append = 
TRUE,  : 
  unable to append to table 'CreditLadderData'

Does sqlSave support this behavior, or do I have to construct the INSERT 
statement myself/modify sqlsave and odbcUpdate to be more lenient (if 
that's possible)?


The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.

More information about the R-help mailing list