I tried to use the parameters in the request, but I (or my system) had a problem with dates.
I am connecting to MS SQL Server
and determine the specific date that I want to process
endDate <- '02.08.2015' My query looks like this:
test <-"SELECT [RDate],[Currency_ID],[Rate],[NRate] FROM [dwh].[dbo].FC_CurrencyRate] WHERE RDate = ? " sqlExecute(myconn,test, endDate)
This gives the following error:
Error in sqlExecute (myconn, test, endDate): 22018 0 [Microsoft] [SQL Server Native Client 11.0] Invalid character value for cast specification
[RODBCext] Error: SQLExecute failed
Optional: Warning message: In sqlExecute (myconn, test, endDate): 22018 0 [Microsoft] [SQL Server Native Client 11.0] Invalid character value for cast specification
Then I tried changing the date format
endDate <- as.Date(endDate, format='%d.%m.%Y') sqlExecute(myconn,test, endDate)
but this leads to another error
Error in sqlExecute (myconn, test, endDate): 07006 0 [Microsoft] [SQL Server Native Client 11.0] Attribute violation with limited data type
Error [RODBCext]: SQLBindParameter Error
Optional: Warning message: In sqlExecute (myconn, test, endDate): 07006 0 [Microsoft] [SQL Server Native Client 11.0] Attribute violation with limited data type
Is this a typical problem? Are there other types of date format using R?
Did I also try covering a question mark? quotes like ??. This caused Rstudio to crash and the request time was too long.
Any hint is appreciated