Avatar of sfletcher1959
sfletcher1959
Flag for United States of America asked on

MS SQL Linked Server using Open Query causing catastrophic failure

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.
Microsoft SQL Server

Avatar of undefined
Last Comment
sfletcher1959

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rich Weissler

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
sfletcher1959

ASKER
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 Weissler

Are any of your columns particularly long?  On the linked server, do you have 'Allow Inprocess' checked?
sfletcher1959

ASKER
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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Rich Weissler

> 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...)
sfletcher1959

ASKER
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 Weissler

I'm sorry, I didn't specify... uncheck Allow Inprocess, and try the query again.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sfletcher1959

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

ASKER
Anyone have any other options???
Rich Weissler

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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
sfletcher1959

ASKER
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 Pletcher

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.
sfletcher1959

ASKER
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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Vitor Montalvão

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
sfletcher1959

ASKER
Vitor,

I copied the query you provided and when I run it I getSQL error
Vitor Montalvão

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.
sfletcher1959

ASKER
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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Vitor Montalvão

Did you check in MSDASQL provider?
sfletcher1959

ASKER
YesQuery 2
sfletcher1959

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

No answer
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sfletcher1959

ASKER
Closing