Heterogeneous Queries, Linked servers, Crystal

I have written a stored procedure  Crystal report.  The stored proc has a select..... with  an inner join to a linked server table (not a view).   I create the SP with the setting of ANSI_NULLS and ANSI_WARNINGS ON as most of the threads here say to do.  The SP runs great in SSMS (Management studio).     But when I go to run it in Crystal, I get the familair "Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection....."
I have gone to the server I am linking to, and set the instance > properties > connections, and checked ansi warnings and ansi nulls.    still get the error.

This is all running under SQL Server 2012 (Express)  64 bit.
fhcdaverpresidentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Don't activate in the instance. Do that when you create the SP:
SET ANSI_WARNINGS ON
SET ANSI_NULLS ON 

CREATE PROCEDURE ProcedureName
 (...)

Open in new window

0
fhcdaverpresidentAuthor Commented:
Hi,

it IS in the SP create:

SET ANSI_NULLS ON
set ansi_warnings on
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROC [dbo].[p_....]

Again, the proc runs OK if I run it in SQLManagement Studio.  It does not run from Crystal XI
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Can you check in there's a why to configure the connection from CR to MSSQL to SET ANSI_NULLS ON and SET ANSI_WARNINGS ON?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

James0628Commented:
I have no idea if this will help, but I ran into this problem at least once.  The stored procedure was trying to build a temp table using data from an Excel file.  I handled the problem by creating a second stored procedure that built the temp table, and executing that SP from the original SP.  That may not be the best solution, but it worked in that particular situation.

 James
0
fhcdaverpresidentAuthor Commented:
I will try the SP - calling an SP approach.
I'm wondering if the SP should select from a view?
0
James0628Commented:
> I'm wondering if the SP should select from a view?

 Honestly, I have no idea.  I never used views much (I didn't have anything against them.  I just didn't use them).  So I really don't know if that will make a difference.

 James
0
fhcdaverpresidentAuthor Commented:
Nope, even using a view instead of a stored procedure still got me the heterogeneous error.  it's definitely something with how Crystal is using or calling the db and the linked sevrer in particular.  

OK, gonna try the temp table route next.
0
fhcdaverpresidentAuthor Commented:
OK, so I did an SP that sleelcts from the "home" server and the linked server the data I need, and it writes to a ##temp table.  Then I have an "enveloping" SP that calls this first one, and then returns the results of the select * from ##temp.

It runs great in SSMS.  but, dammit, if Crystal still bombs looking for the heterogeneous query looking for ansi nulls and ansi warnings.

I wonder if there were options in the creation of the linked server that need to be set?
0
fhcdaverpresidentAuthor Commented:
Vitor,

you say

<Can you check in there's a why to configure the connection from CR to MSSQL to SET ANSI_NULLS ON and SET ANSI_WARNINGS ON?>

I'd love to! do any experts out there know how to check the connection?  

It's an ODBC connection
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
I heard about something called Database Expert in Crystal Reports where you can do something like this:
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON

exec SP_NameHere {@Param1}, {@Param2}

Open in new window

0
James0628Commented:
It runs great in SSMS.  but, dammit, if Crystal still bombs looking for the heterogeneous query looking for ansi nulls and ansi warnings.

 I'm not sure what else to tell you.  I sounds like you're doing the same thing, and it worked for me, but, FWIW, that was years ago.

 You could try Vitor's suggestion.  You can create a "Command" in CR, which is just a query that you enter manually, and apparently you can execute a SP from a Command.  Unfortunately, changing the datasource like that may require recreating the report from scratch.  I'm not sure.

 IAC, to test the idea, you could create a new report, use "Create New Connection", select your db connection and there should be an "Add Command" option.  That should open the Command editor window, where you would enter something like the lines that Vitor posted.  Note that if the SP has any parameters, the corresponding report paramaters should be created in that window.  Unless CR has changed, you can only use parameters in a Command that were created in the Command editor.  Once you've created a parameter, you can double-click on it to add it to the Command.

 Then I guess you'd just need to save the Command, put some fields on the report and try running it.

 James
0
fhcdaverpresidentAuthor Commented:
I will try these things.  
I am wondering if the creation of the Linked Server needed to have these ANSI parameters set.  That seems to be the place where Crystal is falling over.    It's the Linked Server.     But what I don't know is how to either delete and re-create with proper parameters, or somehow have Crystal "override" these linked server parameters so that it's happy.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
You can try to create the linked server inside the SP but I don't know if it will helps:
exec sp_addlinkedserver
@server = 'ServerName\InstanceName',
@srvproduct=N'',
@provider=N'SQLNCLI'

Open in new window

0
mlmccCommented:
What database connection method are you using in Crystal?

If ODBC, check the connection and set those options.

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fhcdaverpresidentAuthor Commented:
Mike,

You did it again.  Thanks.

Yes, it was the ODBC.  So a few things:
1).  I tried setting BOTH ANSI boxes in the ODBC early on, and still had the failure.   But I think that was prior to setting the ANSI's in the SP create.  
2).  The same ODBC works fine in many other Crystals I have.  This is the first, however, with a linked server table join.
3). I ONLY set the ODBC "Use ANSI nulls, paddings and warnings.  
report runs!

thank you all.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.