Discussion:
[R] Help: sqlSave Error
bruclee
2011-11-10 05:28:01 UTC
Permalink
I am using sqlSave to save my data into an existing table at MS SQL Server
database. Previously my code ran smoothly but all of a sudden it stopped
working. Here is my code:

sqlSave(con, highVol, "dbo.futuresHighVol", append=TRUE, rownames=FALSE)

Error: sqlSave(con, highVol, "jrgchis.dbo.futuresHighVol", append = TRUE, :
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]
'futuresHighVol' already exist
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE
jrgchis.dbo.futuresHighVol ("TradeTime" varchar(255), "vol" float)'

Please Help!!!



--
View this message in context: http://r.789695.n4.nabble.com/Help-sqlSave-Error-tp4022523p4022523.html
Sent from the R help mailing list archive at Nabble.com.
Jeff Newmiller
2011-11-10 17:20:06 UTC
Permalink
The error seems clear enough to me... sqlSave is trying to create the table but it already exists.

Some possible directions you could take:

1) Do your work on a particular instance of the table within a single transaction and rollback at the end.
2) Delete the table before you run sqlSave.
3) Explicitly create the table once and keep it, deleting data before re-using it, and use the append option.
4) Include a column that distinguishes between different blocks of data and keep all of the data you add to it.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Post by bruclee
I am using sqlSave to save my data into an existing table at MS SQL Server
database. Previously my code ran smoothly but all of a sudden it stopped
sqlSave(con, highVol, "dbo.futuresHighVol", append=TRUE,
rownames=FALSE)
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]
'futuresHighVol' already exist
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE
jrgchis.dbo.futuresHighVol ("TradeTime" varchar(255), "vol" float)'
Please Help!!!
--
http://r.789695.n4.nabble.com/Help-sqlSave-Error-tp4022523p4022523.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...