insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\contact.xls;',
'SELECT * FROM [$Sheet1]')
select * from Persons
This code not working..It is giving the error
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned
message "The Microsoft Jet database engine could not find the object '$Sheet1'.
Make sure the object exists and that you spell its name and the path
name correctly.".
Msg 7350, Level 16, State 2, Line 2
Cannot get the column information from OLE DB provider "Microsoft.Jet.OLEDB.4.0"
for linked server "(null)".
Please help
It turns out that The Microsoft Jet database engine could not find the object '$Sheet1', and so you should Make sure the object exists and that you spell its name and the path name correctly.
Identify the name of the sheet you are trying to "connect" to. Have a look at the picture above. The standard sheets are called "Sheet1" to "Sheet3". Your workbook under D:\contact.xls probably has custom names. Use the name you find there and add a $ to the end of it.
'SELECT * FROM [Sheet1$]'
Related
I am getting this annoying error, but the thing is that I do not use any JOIN operation in my query. Here is the snippet:
('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\Users\tcmnoc\Desktop\Test.xlsx;','SELECT * FROM ([TradeCloud].[dbo].[Adminlist]')
Select * from [TradeCloud].[dbo].[Adminlist]```
Assuming your snippet derives from an OPENROWSET query, you are conflating data sources where you attempt to reference an SQL Server table inside an Excel connection. When connecting to an Excel workbook as a data source, you can only reference Excel worksheets, not SQL Server tables.
Therefore, this source is not recognizable: [TradeCloud].[dbo].[Adminlist] (correcting the opening parenthesis with square bracket). Instead, connect to an actual Excel worksheet within the workbook connection, placing the named reference outside of the connection string. Below query (after you adjust mySheet should work to retrieve Excel-only data):
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=C:\Users\tcmnoc\Desktop\Test.xlsx;',
[mySheet])
Without fuller context, I consider the following assumptions:
Maybe Excel is connected to the [TradeCloud].[dbo].[Adminlist] table? If so, you need to make a separate, direct connection to the database and schema to access the table (bypassing Excel which is just another client connection).
Maybe you meant to populate an existing SQL Server table? If so, run the needed append or create-table command then browse its contents:
-- APPEND TO TABLE
INSERT INTO [TradeCloud].[dbo].[Adminlist] (Col1, Col2, Col3, ...)
SELECT xl.Col1, xl.Col2, xl.Col3, ...
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=C:\Users\tcmnoc\Desktop\Test.xlsx;',
[mySheet]) xl;
-- CREATE TABLE
SELECT xl.Col1, xl.Col2, xl.Col3, ...
INTO [TradeCloud].[dbo].[Adminlist]
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=C:\Users\tcmnoc\Desktop\Test.xlsx;',
[mySheet]) xl;
-- BROWSE CONTENTS
SELECT * [TradeCloud].[dbo].[Adminlist];
Maybe you are attempting to populate an Excel workbook? If so, do note, these commands (OPENROWSET and OPENDATASOURCE) do not populate an existing Excel workbook but simply connects to external sources (Excel, Access, or other data sources) as a backend to retrieve data.
Good Afternoon All,
I have spent about 6 hours trying to get formatting to work through SSIS using a Max Date Variable to identify into a where clause - Just have no luck!
I have created a variable called my_date which fetched the Max(Date) from a local SQL server table to understand the last load point for that table - using the below code:
SELECT CAST(FORMAT(MAX(Business_Date), 'dd-MMM-yyyy') AS varchar) AS my_date FROM Table
This fetches the date correctly as 17-Sep-2018.
I have then mapped my result set as my_date -> User::max_date
I have set my max_date variable to a string data type under the package scope.
I have tested my variable out by using breakpoints to ensure this runs all the way through in the correct format - and this works 100%.
I then have a data flow task running to fetch data from my ORACLE DB to insert into my SQL Server table which contains the following SQL command:
SELECT *
FROM Table2
WHERE (BUSINESS_DATE > to_date('#[User::max_date]', 'DD-MON-YYYY'))
However I get the ORA-01858 - [TABLE] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E07.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E07 Description: "ORA-01858: a non-numeric character was found where a numeric was expected
".
If I go and replace my variable directly with the contents of the variable shown by the breakpoint in locales it works perfectly!
I have attempted multiple format types from the initial export through to the final where clause and this seems to be the closest I have come to pushing it through but it is still complaining about format.
Please help - Images below to help see setup.
Control Flow - displaying the execute SQL and the data flow task
Locale showing Variable is inserting after breakpoint is reached
Managed to get it working!
By adding an intermediary variable where the value and expression contains the following:
"SELECT *
FROM TABLE
WHERE (BUSINESS_DATE > to_date('"+#[User::max_date]+"' , 'DD-MON-YYYY'))"
I then amended my source OLEDB to SQL Command from variable and selected the above variable created and it worked perfectly!
Try mapping your user parameter in the "OLE DB Data Source Editor", under "Parameters".
1) Change SQL Command Text (change #[User::max_date] to ?), like this:
SELECT *
FROM Table2
WHERE (BUSINESS_DATE > to_date('?', 'DD-MON-YYYY'))
2) Then in the parameter editor, map parameter 1 to #[User::max_date].
https://learn.microsoft.com/en-us/sql/integration-services/data-flow/map-query-parameters-to-variables-in-a-data-flow-component?view=sql-server-2017
Also, the "Oracle Provider for OLE DB" behaves differently than the "Microsoft OLE DB Provider for Oracle", so it depends which you are using.
I have a linked server using ADSI. I can successfully query for most attributes except description.
My query:
SELECT * FROM OpenQuery (ADSI,
'SELECT description,sn,givenName
FROM ''LDAP://mydomain.com/OU=users,DC=com,DC=mydomain''
WHERE title<>''Virtual'' AND (userAccountControl=''66048'' OR
userAccountControl=''512'')')
ORDER BY sn
It throws this error:
"Cannot get the data of the row from the OLE DB provider "ADSDSOObject" for linked server "ADSI". Could not convert the data value due to reasons other than sign mismatch or overflow."
What is the problem here?
The field description is multivalued.
See here:
https://msdn.microsoft.com/en-us/library/ms675492(v=vs.85).aspx
SQL Server does not support multivalued fields and therefore you won't be able to get that one in your query.
Here's a real head scracther (at least for me)
I'm running a query let's say it's:
SELECT number FROM equipment e
left outer join OPENQUERY(ORACLESERVER, 'SELECT num FROM equip_nums WHERE MODEL_NO = ''FOOBAR''') ora
ON e.number = ora.num
WHERE num IS NULL
AND remove = 'no'
AND used = 'yes'
AND model = 'FOOBAR'
This query is run for a number of models, about 50 of them. It works FINE for 47 of those models. But then it fails giving the following error:
OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLESERVER" returned message "ORA-01403: no data found".
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLESERVER".
Now, I know what you're thinking.. "The query in the OPENQUERY is coming back empty, you need to handle that!" And while I agree that case should be handled.. The problem is that that query shouldn't be coming back empty! If I run this query from the same server
SELECT * FROM OPENQUERY(ORACLESERVER, 'SELECT num FROM equip_nums WHERE MODEL_NO = ''FOOBAR''')
I pull back about 1100 rows. So I feel like there should be data there for the join.
Can anyone shed ANY light on this? I'm really baffled here...
I know this is quite old but since it took me some time figuring this and to save the next who might face the same issue, here is what I found:
Linked Server was probably created using Oracle Provider for OLE DB.
There is an Oracle Bug 12861185 and Doc ID 1462403.1 stating that joining data with an openquery set might result to No data found or Cannot get the data of the row from the OLE DB provider ....
Solution provided is
Use the Oracle ODBC Driver.
If you have access to the ADO generated code than you have the following options:
Use CursorType of adOpenStatic, instead of adOpenForwardOnly.
Use CursorType of adOpenStatic, instead of adOpenForwardOnly.
Use CursorLocation of adUseClient (Microsoft's Cursor Library) instead of adUseServer (Oracle's Cursor Library) - which changes the default CursorType to adOpenStatic.
Increase the fetchsize to the value of the total number or rows.
It might be easier though to have the data fetched to a local table and then joining as already answered.
I am trying to move data from a .dbf file to a table in SQL Server 2008 and am getting the following error on multiple numeric columns:
OLE DB provider "MSDASQL" for linked server "(null)" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].apryr" from OLE DB provider "MSDASQL" for linked server "(null)". Conversion failed because the data value overflowed the data type used by the provider.
It only happens on numeric columns and not on every numeric column. Character data is fine and there is no date/time data that could give any issues.
Here is a sample of the code I'm using:
insert into [table] select * from OPENROWSET('MSDASQL',
'DRIVER=Microsoft Visual FoxPro Driver;
SourceDB=[filepath];
SourceType=DBF',
'select *
from [file].dbf)
Since the data in the dbf file is customer data, I've been told I can't manually fix the garbage data in the file (assuming there is any) and everything has to be done through the SQL code. I have searched around the internet and haven't really found a solution to this problem. I'd appreciate any help.
Thank you.
Without knowing more specifics, the situation sounds simple enough: There is data in the dbf file that does not match the data(s) type in your SQL Server table. If that is the case, then you have two options:
Change your SQL Server table to accommodate the data in your dbf file.
Do not import data from the dbf file that is causing the issue.
In option #1, you could modify restrictive numeric or date-type fields to varchar or nvarchar fields. Then, you would want to modify any programs that might be assuming certain data types in the dbf file to accommodate varchar or nvarchar data. For instance you could use some kind of try-catch language that tests the conversion of data before letting a program have access to it.
If you decide to go with option #2, you can change your select query to be filter out data that does not meet the field requirements of your SQL Server table(s).
Good luck!
Check your field types on SQL Server table. Maybe some of them unable to take your DBF's BCD value.