sqlQuery: impossible to get the ID number as Character into R?

前端 未结 2 414
生来不讨喜
生来不讨喜 2021-01-18 06:26

I\'m using the RODBC package inside an ORACLE DATA BASE (DB). Everything is doing very well, but I need to obtain a table from this DB and some variables as cha

相关标签:
2条回答
  • 2021-01-18 06:44

    Change the query to cast the id to the data type you want:

    select distinct cast(t.fono_id_dis as varchar(255)) as id
    . . . 
    

    This should work with most databases.

    0 讨论(0)
  • 2021-01-18 06:49

    This works for me:

    library(RODBC)
    con <- odbcDriverConnect('driver={SQL Server};server=[your server name];database=[your database name];trusted_connection=true')
    ManzResul_VIII<-sqlQuery(con,"select distinct ('m' + id) as id from [your table]")
    
    0 讨论(0)
提交回复
热议问题