I have a SQL database (2012) that I am trying to access through R (R Studio). From Enterprise Manager this is what it looks like:
select top 5[date],value from dbo.history
1991-02-11 11.1591
1991-02-12 11.2
1991-02-13 11.3501
1991-02-14 11.37
1991-02-15 11.3002
However from R this is what I get:
sqlQuery(DF_CN,'select top 5 [date],value from dbo.history')
date value
1 0011-02-19 11.16
2 0012-02-19 11.20
3 0013-02-19 11.35
4 0014-02-19 11.37
5 0015-02-19 11.30
When I try and select all the data from the table, this is what I get
sqlQuery(DF_CN,'select * from dbo.history')
Error in charToDate(x) :
character string is not in a standard unambiguous format
It may to be something about the yyyy-mm-dd default format from SQL server which I can change if I use CONVERT, but this looks like a hack and the SELECT * would not work.
Is there something in R I can do to recognise the SQL Server dates?
Ben
This is driving me nuts - surely someone has seen this before - there is a clear disconnect between the SQL Server output and what R is reading.
I am using RStudio 0.98.1091 and R x64 3.1.2.
Sql Server 2014
Microsoft SQL Server Management Studio 12.0.2000.8
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 4.0 6.0
Microsoft Internet Explorer 9.10.9200.17148
Microsoft .NET Framework 4.0.30319.18444
Operating System 6.1.7601
ODBC Driver 11 for SQL Server.
Everything looks up to date on my system.
the [date] column was of type DATE, is now DATETIME. I now get this;
sqlQuery(DF_CN,('select * from dbo.history')
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
It looks like some disconnect between SQL server setup and R setup.
I worked it out by using the as.is parameter:
sqlQuery(DF_CN,'select * from dbo.history',as.is=T)
Then casting the values I needed directly in R.
I have worked it out.
Driver set to SQL server Native Client 11.0
ODBC settings - Use regional settings when outputting currency, numbers, dates and times switched off.
I am thinking that SQL Server has its own ideas on regional settings rather than what has been provided by windows causing great confusion.
Related
There is some kind of pre-processment of the SQL text on FireDAC queries that truncates their string literals containing ! characters.
It's very easy to replicate:
Place a TFDConnection, a TFDQuery connected to the connection, a TDatasource connected to the query and a TDBEdit connected to the datasource.
After setting my server configuration on the TFDConnection, if I try this SQL on the TFDQuery : Select 'Hel!o World' as column, I would only see He on the TDBEdit instead of Hel!o World.
It's a problem of FireDAC because the same query runs fine directly on SQL Server Management Studio.
Is there a way to fix o disable this pre-processment of FireDAC ?.
It's Delphi 10.4 and SQL Server 2017 accessed by SQL Server Native Client (I have also tried the same query on Delphi 10.3 and returns the same error).
Thank you.
Our former SSRS base on Windows Server 2010 / SQL Server 2008 R2 / Oracle 11g 64 bit, to present data from Oracle database, it had been worked fine.
After we updated to Windows Server 2012 / SQL Server 2016 / Oracle 12 ODAC 64, then some reports with many parameters, when running show error as:
Query execution failed for dataset 'DataSet1'. (rsErrorExecutingCommand)
After removing the parameters then can run normally.
All report's dataset edition in Report Builder show error:
The selected data extension ORACLE is not installed or cannot be loaded. Verify that the selected data extension is installed on the client for local reports and on the report server for published reports.Microsoft.ReportingServices.Designer.Controls)
I had tried to uninstall oracle client 11 then install ODAC121024_x64, later ODTwithODAC121024 (http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html), but all did not work.enter image description here
Now all reports modification are pending, Can expert give me suggestion and idea?
Many thanks in advance!
I have a SQL Server 2012 database with an Access 2007 front-end. My problem is that Access does not recognise SQL Server's dates as they are in a different format.
SQL Server-s format is YYYY-MM-DD
Access' format is DD-MM-YYYY
When the date is displayed in a text-box, it is displayed as a string (without the little calendar icon next to it).
Is there anyway I can configure my Access front-end so that it recognises SQL Server's dates?
I used Microsoft SQL Server Migration Assistant for Access to migrate the data into SQL Server
As this DB is in development I have the SQL Server on my local machine in C drive (no virtual drives)
From my research I have found this answer:
The problem the user has encountered is with a Driver. Microsoft has a new DLL that must be put on a client
workstation (or server in the case of Citrix). Once that is done, all the dates in MS Access will work
properly. My lastest experience with Access 2010 was exactly the same as Access 2003.
It required a DLL. From there, investigate using a DNS-Less connection string
Where would I find this DDL driver and how would I install it.
Thanks
Maggs
I found that SSMA for some reason converted all the datetimes to datetime2. I went into SQL Server Management Studio and changed them to datetimes and it fixed the issue. You could also check the field mapping in SSMA and adjust it before migrating.
(I have the exact same environment - SQL Server 2012 and Access 2007, using SSMA.)
I am using SQL Server 2012 on my local PC (Vista) and have an Access 2010 frontend with ~75 linked tables.
The table in SQL Server has a column named 'EnteredDate' that is defined as 'datetime'.
In Access the 'EnteredDate'column is defined as 'Date/Time'.
In Access, I just ran the following query with proper results:
SELECT DataError.Description, DataError.EnteredDate
FROM DataError
WHERE (((DataError.EnteredDate) Between #1/1/2010# And #1/31/2010#));
I am trying to connect from SQL Server 2008 R2 into an Oracle Linked Server, but the Oracle Schema has a $ symbol in it. Unfortunately, I can't change the schema name, but it appears to be causing me an issue when trying to extract information using OpenQuery. Is it possible to escape this character?
select *
FROM OPENQUERY(linksrv, 'SELECT * FROM [ABC$SCHEMA].[TABLE] where [ID] = ''ABCD0001'' ') oq
The above gives me an error message as follows:
OLE DB provider "OraOLEDB.Oracle" for linked server "linksrv" returned message "ORA-00903: invalid table name".
The below query works, but it is painfully slow on something that takes half a second to run on the Oracle database so I am hoping OPENQUERY might give me results slightly faster?
SELECT *
FROM [linksrv]..[ABC$SCHEMA].[TABLE]
where [ID] = 'ABCD0001'
GO
Version information:
Microsoft SQL Server Management Studio 10.50.2500.0
Microsoft Analysis Services Client Tools 10.50.2500.0
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 2.0.50727.5456
Operating System 6.1.7601
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
Any assistance would be greatly appreciated!!
Thanks in advance!!
Based on the comments it appears that the syntax should be different for Oracle, where square brackets actually cause problems rather than prevent them:
SELECT *
FROM OPENQUERY(linksrv, 'SELECT * FROM ABC$SCHEMA.TABLE ...') AS oq;
I added linked server on MS SQL SERVER 2008 with Sybase ASE 12.5 databases,
everything works fine, but i've got problem with unicode strings.
from MS SQL when i'am running
"SELECT * FROM OPENQUERY ( SYTEST ,'SELECT Name FROM PRODUCT')"
and the result set contains wrong characters
a?›a??a??a? a?”
a??a??a?¬a??a? a??
Name column in Sybase is of nvarchar type , names are written in unicode.
Problem occurs only when ms sql server is running on windows server operating system,
There is no problem on ms sql-servers running on Windows 7 and XP, where I got correct result.
try to use N#parameter when making query
If it works on 2 separate installs, you compare and check the linked server settings using sp_serveroption, especially collation compatible and collation name
If these are the same, check any DSN and Sybase driver settings in the OS
There is a case like this in my company
I've created a linked server from SQL Server 2014 to the IBM AS/400 (i series) and faced with the same problem.
I'm not sure about the different between 2014 and 2008 handle the unicode chars but I think it not much, if any.
How to
1. login to the SQL studio
2. right click the linked server then select "properties"
3. select "Server options" in left pane
4. set "Use remote collation" to "True"
5. in "Collation name", choose your unicode (here is the basic list - https://technet.microsoft.com/en-us/library/ms180175%28v=sql.105%29.aspx"
My problems solved this way! (I played a lot with connection strings with no desired results)