Showing posts with label errorole. Show all posts
Showing posts with label errorole. Show all posts

Wednesday, March 7, 2012

error with OpenRowSet

I'm trying to import a simple excel spreadsheet into MSDE using OpenRowSet,
but receive the following error:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
Connection Closed
here's the sql:
select *
into MyTable
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Default.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')
any help is appreciated...I think it should work if file name is correct. Check whether the file
name is correct
Madhivanan|||Hi
Try this one
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="d:\MyData.xls";
User ID=Admin;Password=;Extended properties=Excel 8.0')...Sheet1$
OR
Specify all columns
insert into MyTable (col1,col2)
SELECT col1,col2
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Default.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')
".bill" <wSweetman@.ucsd.edu> wrote in message news:O3rAPZfHFHA.3612@.TK2MSFTN
GP09.phx.gbl...
I'm trying to import a simple excel spreadsheet into MSDE using OpenRowSet,
but receive the following error:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
Connection Closed
here's the sql:
select *
into MyTable
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Default.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')
any help is appreciated...|||Do you have the file opened in Excel when you try to do this?
That would cause an error, but otherwise the syntax looks ok.
If the file C:\Default.xls exists and has a sheet named
Sheet1, it should work. Does the SQL Server
login have access to that file? What happens if you try
exec master..xp_cmdshell N'dir C:\*.xls'
Steve Kass
Drew University
.bill wrote:

>I'm trying to import a simple excel spreadsheet into MSDE using OpenRowSet,
but receive the following error:
>OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
>Connection Closed
>here's the sql:
>select *
>into MyTable
>FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
> 'Excel 8.0;Database=C:\Default.xls;HDR=YES',
> 'SELECT * FROM [Sheet1$]')
>any help is appreciated...
>
>|||Hi there,
Has anyone found an answer to this yet?
I tried:
insert into tblTestSql (RowNo,RecNo,LdUserName,
Code,LogIn,LogOut)
SELECT RowNo,RecNo,LdUserName,
Code,LogIn,LogOut
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\ReleaseTwo\LogInandOut.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')
Which gives me
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: Unspecified error]
When I try:
exec master..xp_cmdshell N'dir c:\ReleaseTwo\LogInandOut.xls'
I get
The system cannot find the file specified.
Any ideas?
Paul
".bill" wrote:

> I'm trying to import a simple excel spreadsheet into MSDE using OpenRowSet
, but receive the following error:
> OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
> Connection Closed
> here's the sql:
> select *
> into MyTable
> FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
> 'Excel 8.0;Database=C:\Default.xls;HDR=YES',
> 'SELECT * FROM [Sheet1$]')
> any help is appreciated..|||Hi Paul,
The file is in the local machine and you might have run the query in
the server which is not the local machine
Madhivanan|||Hi Madhivanan,
It dosn't matter whether the excel (or txt/csv) file is on the server on on
my local machine I get the same result.
Paul.
"Madhivanan" wrote:

> Hi Paul,
> The file is in the local machine and you might have run the query in
> the server which is not the local machine
> Madhivanan
>|||Paul,
How do you know the file exists?
If it does, and exec master..xp_cmdshell N'dir
c:\ReleaseTwo\LogInandOut.xls' fails,
it's not a problem with OPENROWSET. It sounds like the account used by
SQL Server does not have permission to access the Excel file.
SK
Paul in Harrow wrote:
>Hi there,
>Has anyone found an answer to this yet?
>I tried:
>insert into tblTestSql (RowNo,RecNo,LdUserName,
>Code,LogIn,LogOut)
>SELECT RowNo,RecNo,LdUserName,
>Code,LogIn,LogOut
>FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
> 'Excel 8.0;Database=C:\ReleaseTwo\LogInandOut.xls;HDR=YES',
> 'SELECT * FROM [Sheet1$]')
>Which gives me
>Server: Msg 7399, Level 16, State 1, Line 1
>OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
>[OLE/DB provider returned message: Unspecified error]
>When I try:
>exec master..xp_cmdshell N'dir c:\ReleaseTwo\LogInandOut.xls'
>I get
>The system cannot find the file specified.
>Any ideas?
>Paul
>".bill" wrote:
>
>|||> How do you know the file exists?
Because I created it.

> If it does, and exec master..xp_cmdshell N'dir
> c:\ReleaseTwo\LogInandOut.xls' fails,
> it's not a problem with OPENROWSET. It sounds like the account used by
> SQL Server does not have permission to access the Excel file.
I've just shown that to my techie and he's looking blank! How do I/we find
out what permissions SQL Server has & how do I/we (proberly me) change them?
Many thanks
Paul.|||
Paul in Harrow wrote:

>Because I created it.
>
>
>I've just shown that to my techie and he's looking blank! How do I/we find
>out what permissions SQL Server has & how do I/we (proberly me) change them
?
>
>
It might be as simple as: navigate to the file in Windows Explorer,
right-click, go to the security tab, and make sure the file is available
to the account under which the SQL Server service is running.
But managing Windows accounts is not my strong point, so you could also
look at "Setting up Windows Services Accounts" in Books Online and
see what you find on Usenet:
http://groups.google.co.uk/groups? ...missions%20file
http://www.google.co.uk/search? q=%...missions%20file
For the openquery statement to work, you should be able to log on to
Windows with the same account used by the SQL Server service and
then access the file.
SK

>Many thanks
>Paul.
>

Wednesday, February 15, 2012

Error while converting Oracle Timestamp to Sql Server Timestamp (datetime) - "Invalid date

I am populating oracle source in Sql Server Destination. after few rows it fails it displays this error:

[OLE DB Destination [16]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for SQL Server" Hresult: 0x80004005 Description:
"Invalid date format".

I used this script component using the following code in between the adapters, However after 9,500 rows it failed again giving the same above error:

To convert Oracle timestamp to Sql Server timestamp

If Row.CALCULATEDETADATECUST_IsNull = FalseThen

If IsDate(DateSerial(Row.CALCULATEDETADATECUST.Year, Row.CALCULATEDETADATECUST.Month, Row.CALCULATEDETADATECUST.Day)) Then

dt = Row.CALCULATEDETADATECUST

Row.CALCULATEDETADATECUSTD = dt

EndIf

EndIf

I don't know if my code is right . Please inform, how i can achieve this.

What is the value of the offending row? Redirect the error rows from the SQL dest and see what the offending value is.

The fact that it gets through 9500 rows and then dies means your logic is right but there is a dodgy row.|||

Thanks for your support, Crispin,

I redirected the output at destination (Fail Point) as you said and can see that some columns are displaying the Errors instead of the actual data that gives the clue about which is invalid)

Column 5

Error: Year, Month and day parameters describe an unrepresnatable date and time...

I doubt that the DateSerial function in the script component is unable to extract some formats..

So,

1) Does anybody know which representations and range of Oracle (timestamp) is not allowed in Sql Server (Datetime)
2) Do we have a stable code that can perform Oracle timestamp to Sql Server conversion here

Thanks

Subhash Subramanyam

|||

Hi Experts in SSIS forum,

Thanks to LoRez who has raised this question this month again.. I am still having the same problem in SSIS. I have an Oracle timestamp Source Columns that should be populated into Sql Server Datetime columns. Though I am aware of the ranges valid for both the cases, I was unable to frame it properly. . The expression (This only checks the Date Part , I wanted code that converts the time part of the Oracle timestamp into Sql Server Datetime) I have used to convert this is:

(!ISNULL(REQUESTED_ETA_DATE_CUST) && DATEPART("yyyy",REQUESTED_ETA_DATE_CUST) > 1752 && DATEPART("yyyy",REQUESTED_ETA_DATE_CUST) < 9999) ? REQUESTED_ETA_DATE_CUST : NULL(DT_DBTIMESTAMP)

Though the expression syntax is valid, it still gives error when I run the dataflow. The error is:

[Derived Column [136]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "component "Derived Column" (136)" failed because error code 0xC0049067 occurred, and the error row disposition on "input column "REQUESTED_ETA_DATE_CUST" (372)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

Though http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/7121008802 helps to create a trigger, but not the way we can achieve using SSIS.

Greatly Appreciate if anybody can pointer or paste the Expression or .NET code that can convert Oracle timestamp into Sql Server Datetime without issues

Thanks

Subhash Subramanyam

|||

Dear Umachandar, Thanks for briefing up the approach.

I'd appreciate if you go one step ahead to help my case work.Oracle Timestamp in my case is of the format 'MM/DD/YYYY hh:mm:ss.nnn' and I do not have any control over oracle source. Somehow I must be able to use this to populate the Sql Server datetime. We know that the year should be grater that 1752 which we can validate using above expression. But Validating TimePart seems to be difficult. I tried casting to string, but due to omission of leading zeros makes it difficult to substring that. So do you have a solution for this?

Umachandar's Reply

Oracle timestamp range subsumes that of SQL Server's datetime range. So you will not have any issues as long as you use the ISO 8601 format to specify the values (YYYY-MM-DDT hh:mm:ss.nnn). This will ensure that the value will be stored correctly irrespective of collation settings on either servers or Oracle session setttings. You can use timestamp with appropriate precision on Oracle side (timestamp(3) is closest) to match SQL Server datetime.

Migrating values from Oracle to SQL Server is a different ballgame. You will lose precision, values etc. Oracle has more richer support and wider ranges & ANSI SQL implementation.

Thanks

Subhash Subramanyam

|||

I've put up an article for this on my blog.

Cast this Oracle timestamp Column REQUESTED_ETA_DATE_CUST as below:

Decode(trunc((Extract(YEAR from REQUESTED_ETA_DATE_CUST))/1753), 0,'01/01/1753 12:00:00 AM', TO_CHAR(REQUESTED_ETA_DATE_CUST, 'MM/DD/YYYY hh:mmTongue Tieds AM')) as REQUESTED_ETA_DATE_CUST

Or

Go for filtering valid ranges using SSIS transform after casting into a accepted datetime format.