Sunday, March 11, 2012
Error converting data type DBTYPE_DBTIMESTAMP to datetime
SELECT CAST(cancel_dt as datetime) FROM OPENQUERY(orcldb, 'SELECT cancel_dt FROM tablename WHERE id= 12345')
The date in Oracle is 19-JUN-99, but it's coming over as 06/19/0999 and it throws the error because the year 999 is invalid in SQL Server. Any ideas on why Oracle or SQL server would convert the year to 0999 instead of 1999?
This is also happening on a value 24-SEP-07 coming over as 09/24/0207
Most other date values work, so I'd really like to get in depth into the process that occurs when converting to a SQL Server datetime.Why not use the conversion function in Oracle to produce a 4 digit year?|||I found the problem to be that SQL Server only accepts dates from January 1, 1753 through December 31, 9999 whereas Oracle allows dates January 1, 4712 BC to December 31, 9999 AD.
So these dates that are coming over with years of 999 or 207 produce an error because they are invaild in SQL Server.|||That's correct...
M$ figured that because the calendar was adjusted in that century..(they lost several days) that the date function would produce invalid results...think DATEDIFF, DATEADD, ect
lunacy
anyway...your dates are not 0999
Oracle has the ability to produce the dates you need. The date formatting function in Oracle are far superior to SQL Server...
Just return that date as a varchar in your select, then convert it...|||So what is the actual 4-digit year representation for 19-JUN-99? Is it 06/19/0999 or 06/19/1999?
And what about 24-SEP-07? 09/24/0207 or 09/24/2007?
If the latter is the answer to both then it's not SQL Server, it's how you bring the data in and how much guessing you want SQL Server to do. You also need to check "two digit year cutoff option".|||MY problem with the dates is that 19-JUN-99 is supposed to be 1999, but somehow this date was loaded as June 19, 999 instead. So it is coming over correctly. There's just some data cleaning to be done.
This is what happens when you use someone elses data :mad:|||These 2 calls produce the right result:
select cast('24-SEP-07' as datetime) --09/24/2007
select cast('19-JUN-99' as datetime) --06/19/1999|||Check how you set up the linked server to Horacle. See if there is any datetime/currency setting that can affect this.
Error converting data type DBTYPE_DBTIMESTAMP to datetime
Hi
I am trying to transfer data from Access 2000 database to SQL server 2005 via SSIS. My access database table has a field with data type Date/Time and SQL server table has a field with data type datetime. When I am running the SSIS package, it is throwing the following error and stops execution.
[SQL Server Destination [12466]] Error: An OLE DB error has occurred. Error code: 0x80040E07. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E07 Description: "Error converting data type DBTYPE_DBTIMESTAMP to datetime.".
Please help.
Thanks in advance,
Ramzee
Thanks Darren!
I used the script component to identify the wrong date entries. Now it works!
Thanks once again.
|||I am having the same error. A simple select from Query Analyzer
Select * from HCPROD..HC.UNIT U
Even if I specifically reference a number column I get the same error
Select BLOCK_ID from HCPROD..HC.UNIT U
The way I see it is that there is a column, probably the DATE_MODIFIED column, somewhere in the database that has a date & time value that the driver cannot process. Why the error occurs even if I do not reference the column is a mystery.
I am using Microsoft OLE DB Provider for Oracle
Note that I have insured that every date field in the table is in 20th or 21st century
|||Some more information. We are using Oracle version 10g. I wonder if there is an updated driver from Microsoft? We searched and could not find one ourselves.|||SELECT TOP 10 * FROM [ORACLE_LOOKUP]..[SchemaName].[TableName] AlaisName
Error converting data type DBTYPE_DBTIMESTAMP to datetime
SELECT * FROM
OPENQUERY (
ORACLE_LOOKUP,
'SELECT TO_CHAR(DateColumnName) FROM TableName')
The following workaround was foud on the internet
A workaround would be to use the OPENQUERY function in SQL Server. This
function allows you to execute a pass-through query on the linked server.
By issuing a pass-through query, you can then take advantage of Oracle's
built-in functions to convert the date to a character data type or NULL.
Examples of both are as follows:
In the following example, the column "hiredate" is converted to a string in
the format of MM-DD-YYYY.
SELECT *
FROM OPENQUERY(, 'SELECT empno,
TO_CHAR(hiredate,''MM-DD-YYYY'') FROM scott.emp')
In this example we use a combination of two Oracle built-in functions,
DECODE and GREATEST to convert any hiredate that is earlier than 01/01/1753
(SQL Server's lower bound) to NULL.
SELECT *
FROM OPENQUERY(,'SELECT DECODE (hiredate,
GREATEST(hiredate, TO_DATE(''01/01/1753'',''MM/DD/YYYY'')), hiredate, NULL)
FROM scott.emp')
In case you are not familiar with Oracle built-ins, here is a description of
the two used in the query above.
DECODE is similar to a case statement in SQL Server. Its syntax is as
follows :
DECODE(, , , , ,...,
)
The is compared to each value. If there is a match,
the corresponding is returned. Otherwise, the value is
returned.
GREATEST returns the greatest value in the list of expressions.
GREATEST(, , ...)
Reply With Quote
Friday, March 9, 2012
Error converting data type DBTYPE_DBTIMESTAMP to datetime
Hi
I am trying to migrate data from oracle to sql server 2005 in sql server management studio express, most of my data in oracle have been successfully moved into sql server 2005 by using storage procedure. But some of data can't move across becasue i got this error:
Error converting data type DBTYPE_DBTIMESTAMP to datetime
Does anyone know why? Please help?
Thanks
Li
There is "invalid" datetime data in one of the columns, thi could be based on a out-of-range value or another date representation which does not fit the destination one. If you cannot identitfy the values which cannot be imported, try to import the data to SQL Server using a VARCHAR or CHAR destination data type and find out which values are malicious using the ISDATE Function.
HTH, jens K. Suessmeyer.
http://www.sqlserver2005.de
Error converting data type DBTYPE_DBTIMESTAMP to datetime
Hi
I am trying to transfer data from Access 2000 database to SQL server 2005 via SSIS. My access database table has a field with data type Date/Time and SQL server table has a field with data type datetime. When I am running the SSIS package, it is throwing the following error and stops execution.
[SQL Server Destination [12466]] Error: An OLE DB error has occurred. Error code: 0x80040E07. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E07 Description: "Error converting data type DBTYPE_DBTIMESTAMP to datetime.".
Please help.
Thanks in advance,
Ramzee
Thanks Darren!
I used the script component to identify the wrong date entries. Now it works!
Thanks once again.
|||I am having the same error. A simple select from Query Analyzer
Select * from HCPROD..HC.UNIT U
Even if I specifically reference a number column I get the same error
Select BLOCK_ID from HCPROD..HC.UNIT U
The way I see it is that there is a column, probably the DATE_MODIFIED column, somewhere in the database that has a date & time value that the driver cannot process. Why the error occurs even if I do not reference the column is a mystery.
I am using Microsoft OLE DB Provider for Oracle
Note that I have insured that every date field in the table is in 20th or 21st century
|||Some more information. We are using Oracle version 10g. I wonder if there is an updated driver from Microsoft? We searched and could not find one ourselves.|||SELECT TOP 10 * FROM [ORACLE_LOOKUP]..[SchemaName].[TableName] AlaisName
Error converting data type DBTYPE_DBTIMESTAMP to datetime
SELECT * FROM
OPENQUERY (
ORACLE_LOOKUP,
'SELECT TO_CHAR(DateColumnName) FROM TableName')
The following workaround was foud on the internet
A workaround would be to use the OPENQUERY function in SQL Server. This
function allows you to execute a pass-through query on the linked server.
By issuing a pass-through query, you can then take advantage of Oracle's
built-in functions to convert the date to a character data type or NULL.
Examples of both are as follows:
In the following example, the column "hiredate" is converted to a string in
the format of MM-DD-YYYY.
SELECT *
FROM OPENQUERY(, 'SELECT empno,
TO_CHAR(hiredate,''MM-DD-YYYY'') FROM scott.emp')
In this example we use a combination of two Oracle built-in functions,
DECODE and GREATEST to convert any hiredate that is earlier than 01/01/1753
(SQL Server's lower bound) to NULL.
SELECT *
FROM OPENQUERY(,'SELECT DECODE (hiredate,
GREATEST(hiredate, TO_DATE(''01/01/1753'',''MM/DD/YYYY'')), hiredate, NULL)
FROM scott.emp')
In case you are not familiar with Oracle built-ins, here is a description of
the two used in the query above.
DECODE is similar to a case statement in SQL Server. Its syntax is as
follows :
DECODE(, , , , ,...,
)
The is compared to each value. If there is a match,
the corresponding is returned. Otherwise, the value is
returned.
GREATEST returns the greatest value in the list of expressions.
GREATEST(, , ...)
Reply With Quote
Error converting data type DBTYPE_DBTIMESTAMP to datetime
Hi
I am trying to transfer data from Access 2000 database to SQL server 2005 via SSIS. My access database table has a field with data type Date/Time and SQL server table has a field with data type datetime. When I am running the SSIS package, it is throwing the following error and stops execution.
[SQL Server Destination [12466]] Error: An OLE DB error has occurred. Error code: 0x80040E07. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80040E07 Description: "Error converting data type DBTYPE_DBTIMESTAMP to datetime.".
Please help.
Thanks in advance,
Ramzee
Thanks Darren!
I used the script component to identify the wrong date entries. Now it works!
Thanks once again.
|||I am having the same error. A simple select from Query Analyzer
Select * from HCPROD..HC.UNIT U
Even if I specifically reference a number column I get the same error
Select BLOCK_ID from HCPROD..HC.UNIT U
The way I see it is that there is a column, probably the DATE_MODIFIED column, somewhere in the database that has a date & time value that the driver cannot process. Why the error occurs even if I do not reference the column is a mystery.
I am using Microsoft OLE DB Provider for Oracle
Note that I have insured that every date field in the table is in 20th or 21st century
|||Some more information. We are using Oracle version 10g. I wonder if there is an updated driver from Microsoft? We searched and could not find one ourselves.|||SELECT TOP 10 * FROM [ORACLE_LOOKUP]..[SchemaName].[TableName] AlaisName
Error converting data type DBTYPE_DBTIMESTAMP to datetime
SELECT * FROM
OPENQUERY (
ORACLE_LOOKUP,
'SELECT TO_CHAR(DateColumnName) FROM TableName')
The following workaround was foud on the internet
A workaround would be to use the OPENQUERY function in SQL Server. This
function allows you to execute a pass-through query on the linked server.
By issuing a pass-through query, you can then take advantage of Oracle's
built-in functions to convert the date to a character data type or NULL.
Examples of both are as follows:
In the following example, the column "hiredate" is converted to a string in
the format of MM-DD-YYYY.
SELECT *
FROM OPENQUERY(, 'SELECT empno,
TO_CHAR(hiredate,''MM-DD-YYYY'') FROM scott.emp')
In this example we use a combination of two Oracle built-in functions,
DECODE and GREATEST to convert any hiredate that is earlier than 01/01/1753
(SQL Server's lower bound) to NULL.
SELECT *
FROM OPENQUERY(,'SELECT DECODE (hiredate,
GREATEST(hiredate, TO_DATE(''01/01/1753'',''MM/DD/YYYY'')), hiredate, NULL)
FROM scott.emp')
In case you are not familiar with Oracle built-ins, here is a description of
the two used in the query above.
DECODE is similar to a case statement in SQL Server. Its syntax is as
follows :
DECODE(, , , , ,...,
)
The is compared to each value. If there is a match,
the corresponding is returned. Otherwise, the value is
returned.
GREATEST returns the greatest value in the list of expressions.
GREATEST(, , ...)
Reply With Quote