Skip to content

Error in importing table from SQL to R

2 messages · Madan Mohan, Seeliger.Curt at epamail.epa.gov

#
Hi Friends,

I am trying to import a table from SQL server to R(2.9.0), however i am
getting errors while running the below codes. Can anyone identify and let me
know where did i go wrong??? Thanks in anticipation :)

library(RODBC)

myconn <- odbcConnect("RDATABASE")
 
myconn

RODB Connection 6
Details:
  case=nochange
  DSN=RDATABASE
  Description=Database for R
  UID=Madana_Babu
  WSID=IBLPN1B049040
  Trusted_Connection=Yes

NEWDATASQL1 <- sqlFetch(myconne, CampaignDataLarge)

Error in odbcTableExists(channel, sqtable) : 
object 'CampaignDataLarge' not found

NEWDATASQL2 <- sqlFetch(myconne, CampaignDataLarge, colnames = FALSE,
rownames = TRUE)

Error in odbcTableExists(channel, sqtable) : 
object 'CampaignDataLarge' not found

NEWDATASQL3 <- sqlFetchMore(myconne, CampaignDataLarge, colnames = TRUE,
rownames = TRUE)

NEWDATASQL3

[1] -1

NEWDATASQL4 <- sqlQuery(myconne, "select * from CampaignDataLarge", errors =
TRUE, colnames = FALSE, rownames = TRUE)

NEWDATASQL4

[1] "[RODBC] ERROR: Could not SQLExecDirect"                                                           
[2] "42S02 208 [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object
name 'CampaignDataLarge'."

Regards,
Madan