New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`dbWriteTable()` fails to write to existing table with non-default schema #191

Closed
EthanTaft opened this Issue Jul 26, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@EthanTaft

EthanTaft commented Jul 26, 2017

Reproducible Example:


#create a table in SSMS 
CREATE TABLE [guest].[MikeTestTable](
[a] [float] NULL,
[b] [float] NULL,
[c] [varchar](255) NULL)

#create a connection string to the database where the table was created
MSSQLConnectionString <- '
  driver={SQL Server};
  server=localhost;
  database=SAM;
  trustedConnection=true;
  '

#DBI Connection
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
                      .connection_string = MSSQLConnectionString)

#small dataframe we want to insert/append to the table we created at the beginning
df <- data.frame(a = c(10, 20, 30),
                 b = c(20, 40, 60),
                 c = c("oneT", "twoT", "threeT"))

#try to write contents of df to the table
DBI::dbWriteTable(conn = con,
                  name = SQL('guest.MikeTestTable'),
                  value = df,
                  append = TRUE)

Error: <SQL> 'CREATE TABLE guest.MikeTestTable (
  "a" FLOAT,
  "b" FLOAT,
  "c" varchar(255)
)
'
  nanodbc/nanodbc.cpp:1587: 42S01: [Microsoft][ODBC SQL Server Driver][SQL Server]
There is already an object named 'MikeTestTable' in the database. 

Question
Why is dbWriteTable trying to create a new table when append = TRUE ?

@EthanTaft

This comment has been minimized.

Show comment
Hide comment
@EthanTaft

EthanTaft Aug 11, 2017

Sorry to write again. Have you guys looked into this issue yet? We are really in need of a solution right now but we know your time is busy. Cheers!

EthanTaft commented Aug 11, 2017

Sorry to write again. Have you guys looked into this issue yet? We are really in need of a solution right now but we know your time is busy. Cheers!

@EthanTaft

This comment has been minimized.

Show comment
Hide comment
@EthanTaft

EthanTaft Aug 22, 2017

Issue solved here

EthanTaft commented Aug 22, 2017

Issue solved here

@JackStat

This comment has been minimized.

Show comment
Hide comment
@JackStat

JackStat Aug 27, 2017

@EthanTaft The link is dead sir. Can you update?

JackStat commented Aug 27, 2017

@EthanTaft The link is dead sir. Can you update?

@EthanTaft

This comment has been minimized.

Show comment
Hide comment
@EthanTaft

EthanTaft Aug 28, 2017

@JackStat Thanks for pointing that out. This link should work.

EthanTaft commented Aug 28, 2017

@JackStat Thanks for pointing that out. This link should work.

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr Dec 4, 2017

Member

Closing, see also #24.

Member

krlmlr commented Dec 4, 2017

Closing, see also #24.

@krlmlr krlmlr closed this Dec 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment