Solved

Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS

Posted on 2012-03-28
1
2,550 Views
Last Modified: 2012-08-13
Can anyone help me in fixing this error. The MsSQL query works fine in a SQL query windows, but not in a PHP page. I have put SET ANSI_NULLS ON; SET ANSI_WARNINGS ON; SET NOCOUNT ON;  before the query but still no luck. Below is the error i get.

Warning: mssql_query() [function.mssql-query]: message: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query. (severity 16) in C:\inetpub\wwwroot\labs\test.php on line 18

Warning: mssql_query() [function.mssql-query]: Query failed in C:\inetpub\wwwroot\labs\test.php on line 18
A error occured: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
0
Comment
Question by:previewservices
1 Comment
 

Accepted Solution

by:
previewservices earned 0 total points
ID: 37776777
Worked it out. Added this BEFORE my statement rather than at the start of the main query.

$result = mssql_query("SET ANSI_NULLS ON;");
$result = mssql_query("SET ANSI_WARNINGS ON;");
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
htaccess block all countries but the US 4 37
Sql case statement to calculate totals 5 34
restriction of entering a a page 5 31
SQL profiler 3 12
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question