character string is not in a standard unambiguous format

Hi ,
I am new to R language.Just few days back started learning the R language.
When i am trying to call the data from the sql server table i am getting the error as
"character string is not in a standard unambiguous format".
Below is the code:
data<-RODBC::sqlFetch(myconn,"Person.Address").
Could you please help me to solve this issue.

This is not a valid sql query, it should be something like

SELECT Person.Address
FROM Person

The exact syntax would depend on the specific sql dialect you are using

I am using Rstudio. Could you please let me know how to write in Rstudio in order to fetch rows from sql server table.

myconn <-RODBC::odbcDriverConnect(connection="Driver={SQL Server Native Client 11.0};server=LENOVO-PC\MSSQLSERVER2012;database=AdventureWorks2012_Data;trusted_connection=yes;")

data<-RODBC::sqlFetch(myconn,"dbo.Employee",colnames=TRUE)

This not depends on Rstudio but in your sql server, this sql query ("dbo.Employee") is not valid sql code.

Its hard to help you since I don't know the structure of your data base, but you need to use a query that follows this pattern

SELECT column_name 
FROM table_name

when i am running the below code then also i am getting same error:
resultset <- RODBC::sqlQuery(myconn, "SELECT *
FROM [AdventureWorks2012_Data].[Person].[Person]")

database=AdventureWorks2012_Data
Table_Name=Person.Person

Hi there,

I tend to agree with previous answer that the issue is related to how you define the query that R should execute.

From my days using SQL server, the sql you are showing have a lot of MSSQL dialect in them. I would suggest to keep the sql simple and use only plain basic standard sql.

Try to use the query as:
select * from person

The database drivers should take care of the rest for you.

Regards,

jm

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.