MS SQL Linked Server using Open Query causing catastrophic failure

sfletcher1959
sfletcher1959 used Ask the Experts™
on
Here is my query:
Select AQ.hwt_user, AQ.Cust_Div_Def_Definit,
AQ.hwt_action, AQ.hwt_entity_id,
AQ.Order_H_PO, AQ.FirstName + ' ' + AQ.LastName as UserName,
AQ.hwt_part_number, AQ.hwt_location_id_wasp,
AQ.hwt_asset_tag, AQ.hwt_serial_number,
AQ.hwt_quantity, AQ.hwt_create_date,
AQ.hwt_create_time, AQ.hwt_entry_date,
AQ.hwt_entry_time, AQ.hwt_processed,
AQ.Prod_Description, location.code as location_code
From
OPENQUERY(CommPlete,
'Select hh_warehouse_trans.hwt_user, Customer_Division_De.Cust_Div_Def_Definit,
hh_warehouse_trans.hwt_action, hh_warehouse_trans.hwt_entity_id,
Order_Header.Order_H_PO,
Rtrim(User_Code_Table.User_First_Name) as FirstName, Rtrim(User_Code_Table.User_Last_Name) as LastName,
hh_warehouse_trans.hwt_part_number, hh_warehouse_trans.hwt_location_id_wasp,
hh_warehouse_trans.hwt_asset_tag, hh_warehouse_trans.hwt_serial_number,
hh_warehouse_trans.hwt_quantity, hh_warehouse_trans.hwt_create_date,
hh_warehouse_trans.hwt_create_time, hh_warehouse_trans.hwt_entry_date,
hh_warehouse_trans.hwt_entry_time, hh_warehouse_trans.hwt_processed,
Product_Catalog.Prod_Description
From hh_warehouse_trans
Inner Join Customer_Division_De
On Customer_Division_De.Cust_Div_Def_Custome = ''2009010101''
And Customer_Division_De.Cust_Div_Def_Divisio = hh_warehouse_trans.hwt_warehouse
Inner Join Product_Catalog
On Product_Catalog.Prod_Customer_No = ''2009010101''
And Product_Catalog.Prod_Customer_Div = hh_warehouse_trans.hwt_warehouse
And Product_Catalog.Prod_Mfr_Part_No = hh_warehouse_trans.hwt_part_number
Left Outer Join Order_Header
On Order_Header.Order_H_Order_No = hh_warehouse_trans.hwt_entity_id
Inner Join User_Code_Table
On User_Code_Table.User_ID = hh_warehouse_trans.hwt_user
Where hh_warehouse_trans.hwt_asset_tag = ''AM00163779''
And hh_warehouse_trans.hwt_action <> ''Move''
And hh_warehouse_trans.hwt_processed = 1
') As AQ Left Outer Join
location On location.location_id = AQ.hwt_location_id_wasp
Order By AQ.hwt_entry_date Desc,
AQ.hwt_entry_time Desc

This works on an older 2003 sp2 server running MS SQL 2005 but fails with a catastrophic failure on a 2012 R2 server running MS SQL 2012.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Professional Troublemaker^h^h^h^h^hshooter
Commented:
You have the linked server "CommPlete" defined on the MS SQL 2012 server?
Can you be more specific concerning what sort of catastrophic failure you are encountering?  (Burning smells?  Parts flying out of the screen, or just an error msg?)

Author

Commented:
Yes "CommPlete" is defined in the Linked Server area and I can see all the tables from that database.

The error message is: The OLE DB provider "MSDASQL" for linked server "CommPlete" reported an error. The provider reported an unexpected catastrophic failure.

I meant to include that in the original post and then forgot.

The interesting thing is it returns the header row just no data.
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooter

Commented:
Are any of your columns particularly long?  On the linked server, do you have 'Allow Inprocess' checked?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I guess it depends on your definition of particularly long. One of the column is a 100 character alpha field. As to the 'Allow Inprocess', I don't know where to look for that. I checked the properties of the linked server but don't find that.
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooter

Commented:
> I guess it depends on your definition of particularly long. One of the column is a 100 character alpha field.

I was thinking in terms of ntext, text, etc.

> As to the 'Allow Inprocess', I don't know where to look for that.

It'll in under 'Providers' below Linked Servers... check the properties of MSDASQL.  (And hopefully this is a test instance, or the only linked server you have using the MSDASQL provider, so it doesn't matter if we test the allow inprocess setting...)

Author

Commented:
The 100 character field is the longest of the selected fields. I guess with the combination of the name field it might be longer but I doubt it.

Found Allow Inprocess and it was already checked.

This is the only linked server and yes this is in our test environment. The older server that I mentioned running Win 2003 and SQL 2005 is our current dev environment.

It is confusing to me that it would work on an older operating system and version of SQL but fail on newer version.
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooter

Commented:
I'm sorry, I didn't specify... uncheck Allow Inprocess, and try the query again.

Author

Commented:
Unchecked it, ran it again and it failed with the same message. Took longer to fail but it still failed.

Author

Commented:
Anyone have any other options???
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooter

Commented:
I'm pretty sure it's a flaw in the data connector driver.  Unfortunately I can't reproduce the issue, but reading what other folks have encountered with similar issues, I'd suggest trying:
Upgrade to at least SP2 possibly SP2 CU7.  (In either event, be sure to pick up MS15-058 for security...)

I see one other suggestion to remove the linked server object, and recreate the linked server after making the necessary changes to the provider.

It seems that it's the number of columns or size of columns returned which is where things break.  Ironically several folks have reported that they've had better luck with returning '*' rather than specifying specific columns, but that appears problematic in this case.  (Might be worth testing/confirming whether a test query returning 'hh_warehouse_trans.*' returns rather than errors.)

And, yes, it seems to track to versions after SQL Server 2008.

Author

Commented:
We have completed the updates and are no longer getting the catastrophic failure.  So that is good.  However, we are now getting the following error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "CommPlete" reported an error. Provider caused a server fault in an external process.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "CommPlete".
Scott PletcherSenior DBA
Most Valuable Expert 2018
Top Expert 2014

Commented:
For the linked server provider, look at the "Allow inprocess" option.  Maybe adjust that and try it again -- disclaimer: naturally, you should technically read up on the potential implications of that change before making it.

Author

Commented:
Scott
We have tried it with Allow inprocess checked and unchecked.  Doesn't make any difference.  I found a MS article stating this was a know bug that would ultimately get fixed.  It provided two workarounds.
You can workaround the problem using either of the following methods:

Workaround 1: Configure the OLEDB provider to run in-process.

Note: You cannot use this workaround for OLEDB providers that are based on .Net versions that are earlier than 4.0.


Workaround 2:Assign the users the "Create global objects" user right. To do this, follow these steps:
Click Start, point to Administrative Tools, and then click Local Security Policy.
Expand Local Policies, and then click User Rights Assignment.
In the right pane, double-click Create global objects.
In the Local Security Policy Setting dialog box, click Add.
In the Select Users or Group dialog box, click the user accounts that you want to add, click Add, and then click OK.
Click OK.

I have tried both without success.  

One note to mention is that under providers I found SQLOLEDB Provider.  Wasn't sure if this was the same provider the work around was referencing.  If it was, I have checked Allow Inprocess.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017
Commented:
Can you make a test without the OPENQUERY function?
I just replace it with a CTE so I'm expecting this to run:
WITH AQ AS
	(Select hh_warehouse_trans.hwt_user, Customer_Division_De.Cust_Div_Def_Definit,
		hh_warehouse_trans.hwt_action, hh_warehouse_trans.hwt_entity_id,Order_Header.Order_H_PO, 
		Rtrim(User_Code_Table.User_First_Name) as FirstName, Rtrim(User_Code_Table.User_Last_Name) as LastName,
		hh_warehouse_trans.hwt_part_number, hh_warehouse_trans.hwt_location_id_wasp,
		hh_warehouse_trans.hwt_asset_tag, hh_warehouse_trans.hwt_serial_number,
		hh_warehouse_trans.hwt_quantity, hh_warehouse_trans.hwt_create_date,
		hh_warehouse_trans.hwt_create_time, hh_warehouse_trans.hwt_entry_date,
		hh_warehouse_trans.hwt_entry_time, hh_warehouse_trans.hwt_processed, Product_Catalog.Prod_Description
	From CommPlete.databasename.dbo.hh_warehouse_trans
		Inner Join CommPlete.databasename.dbo.Customer_Division_De On Customer_Division_De.Cust_Div_Def_Custome = ''2009010101'' And Customer_Division_De.Cust_Div_Def_Divisio = hh_warehouse_trans.hwt_warehouse
		Inner Join CommPlete.databasename.dbo.Product_Catalog On Product_Catalog.Prod_Customer_No = ''2009010101'' And Product_Catalog.Prod_Customer_Div = hh_warehouse_trans.hwt_warehouse And Product_Catalog.Prod_Mfr_Part_No = hh_warehouse_trans.hwt_part_number
		Left Outer Join CommPlete.databasename.dbo.Order_Header On Order_Header.Order_H_Order_No = hh_warehouse_trans.hwt_entity_id
		Inner Join CommPlete.databasename.dbo.User_Code_Table On User_Code_Table.User_ID = hh_warehouse_trans.hwt_user
	Where hh_warehouse_trans.hwt_asset_tag = ''AM00163779'' And hh_warehouse_trans.hwt_action <> ''Move'' And hh_warehouse_trans.hwt_processed = 1)

Select AQ.hwt_user, AQ.Cust_Div_Def_Definit,
	 AQ.hwt_action, AQ.hwt_entity_id,
	 AQ.Order_H_PO, AQ.FirstName + ' ' + AQ.LastName as UserName,
	 AQ.hwt_part_number, AQ.hwt_location_id_wasp,
	 AQ.hwt_asset_tag, AQ.hwt_serial_number,
	 AQ.hwt_quantity, AQ.hwt_create_date,
	 AQ.hwt_create_time, AQ.hwt_entry_date,
	 AQ.hwt_entry_time, AQ.hwt_processed,
	 AQ.Prod_Description, location.code as location_code
From AQ
	Left Outer Join location On location.location_id = AQ.hwt_location_id_wasp
Order By AQ.hwt_entry_date Desc, AQ.hwt_entry_time Desc 

Open in new window

NOTE: Replace databasename with the real database name and I used dbo as default schema but if is it another schema you'll need to replace it too:

Author

Commented:
Vitor,

I copied the query you provided and when I run it I getSQL error
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
In SQL Management Studiogo to Server Object / Linked Servers / Provider and check if any (specially SQLOLEDB) has the “zero level only” property checked. If afirmative then uncheck it and restart SQL Server service.
Now you should be able to run the query again.

Author

Commented:
Checked were indicated and none of the providers had "zero level only" checked. I did restart the SQL Server just in case it was needed but still the same error.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
Did you check in MSDASQL provider?

Author

Commented:
YesQuery 2

Author

Commented:
I've requested that this question be deleted for the following reason:

No answer

Author

Commented:
Closing

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial