Here's the connection we're working with:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "[your driver's name]",
Host = "[your server's path]",
DBCName = "[IP Address or Alias]"
UID = rstudioapi::askForPassword("Database user"),
PWD = rstudioapi::askForPassword("Database password"))
The command below works fine in my code, with no errors, and output that appears correct:
table1 <- tbl(con, "SAP_PRD_QMEL_ACQ")
However, when I run this line of code I get the following error:
table2 <- DBI::dbGetQuery(con, "SELECT * FROM SAP_PRD_QMEL_ACQ LIMIT 5")
#> Error in new_result(connection@ptr, statement) :
#> nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]
#> [Teradata Database](-3706)Syntax error: expected something between the word
#> 'SAP_PRD_QMEL_ACQ' and the 'LIMIT' keyword.
When I create simple repro's to try and duplicate the error I come up empty handed. Why would I be getting this "expecting something between Database_Name and LIMIT" error?
Not going to be able to reproduce your issue, but I believe you will need to use TOP
instead of LIMIT
:
table2 <- DBI::dbGetQuery(con, "SELECT TOP 5 * FROM SAP_PRD_QMEL_ACQ")