Can't query for description from SQL using ADSI - sql

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.

Related

Error handling in SQL and bypassing errors

I'm querying from a linked server that is returning the following error message. The query results look fine but I'm unable to run an INSERT statement using the code because of this. Is there a way to bypass the error and execute the stored procedure anyway. Changing the table design in the data source is not an option.
OLE DB provider 'MSDASQL' for linked server 'ServerName' returned data
that does not match expected data length for column
'[ServerName]..[SQLUser].[STUSER].USERID'. The (maximum) expected data
length is 4, while the returned data length is 5.

SSIS Variable Date Failing between SQL Server and ORACLE

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.

Oracle ORA-01403: No Data Found while doing a JOIN with OPENQUERY on SQL Server

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.

MS Access database: Select statement error

I am trying following query in MS Access 2010 database:
Query:
SELECT ID, Title, Priority, Workflow_Instance_Step_ID:ID
FROM Task
Error:
Error Source: Microsoft Office Access Database Engine
Error Message: Syntax error (missing operator) in query expression 'Workflow_Instance_Step_ID:ID'
I know that field "Workflow_Instance_Step_ID:ID" is giving error as it has ':' operator, but I cant change it as it it coming from share point list.
I have tried '[Workflow_Instance_Step_ID:ID]' but still its giving an error.
Please give me your suggestion on the same.
I am unable to recreate your issue, at least with a native Access table in Access 2010. I created a table named [baz] with a single text field named [foo:bar]
foo:bar
-------
this
is
a
test
and the query
SELECT [foo:bar] FROM baz;
works fine, so a field name containing a colon character does not seem to cause problems for Access SQL as such.
An ODBC linked table to a SQL Server table with the same structure does not cause problems either.
In both cases the queries were run from within Access 2010 itself.
So we might be in diagnosis mode, so lets try
SELECT * FROM Task
and then look at the FieldNames that come back.

Conversion Failed Due To Data Overflow (Numeric)

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.