UPDATE Failed Because The Following SET Options Have Incorrect Settings: 'ANSI_NULLS'
Oct 1, 2007
Hi, i have problem as subject says.
Db has table with 3 columns, ID, Key and Val. ID is primary key, Key has unique index and Val simple holds value in text format.
I have created DAL layer using .netTiers and CodeSmith. Generated procedures.sql has before every procedure set ANSI_NULLS to OFF.
When i read rows from table i print them on screen. When user changes value, that should also be updated in database.
When i select entity, its value is changed.
Here is code snipper.
UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.
Also, class which hold previous code snipper supports caching, by using some kind of SqlCacheManager, which is above SqlCacheDependecy class. Database service broker is started by
Code Block
ALTER DATABASE <DB_NAME> SET ENABLE_BROKER
Server is SqlExpress 2005.
Application is in ASP.NET 2.0.
I also noticed next.
On first run, previous code passes without errors. On second run, update error appears.
This is log from sql server.
Code BlockQuery notification delivery could not send message on dialog '{822C7891-736E-DC11-836B-005056C00008}.'. Delivery failed for notification '<qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotificationhttp://schemas.microsoft.com/SQL/Notifications/QueryNotification">http://schemas.microsoft.com/SQL/Notifications/QueryNotification</A< A>>" id="1" type="change" source="database" info="restart" database_id="13" sid="0xE7C0751C9F7F6C4D9423096BBCC7FB69"><qn:Message>edd3e2dd-11ed-4d92-a0f4-5c674a90aecf;8b2095663cc6a9c297120e4c94d488555e97e54d</qn:Message></qn:QueryNotification>' because of the following error in service broker: 'The conversation handle "822C7891-736E-DC11-836B-005056C00008" is not found.'
When I want to delete a data from a table that this tabl has a triggerand this trigger reached another tables to delete the data in cursor Ihave this messeage:DELETE failed because the following SET options have incorrectsettings: 'QUOTED_IDENTIFIER'.My trigger :CREATE TRIGGER [TOPBASICIKISSILME] ON [dbo].[TBLDEPOBKTOPBASICIKIS]FOR DELETEASBEGINDECLARE @rows_affected int, @inc bigint , @dblid bigint ,@DEPOBKINCbigintSELECT @rows_affected = @@ROWCOUNTIF @rows_affected = 0RETURN -- No rows changed, exit triggerBEGINDECLARE Miktar CURSOR FORSELECT deleted.DBLID,deleted.TOPBASICIKISINC , deleted.DEPOBKINCFROM deletedOPEN MiktarFETCH NEXT FROM Miktar INTO @dblid,@inc,@DEPOBKINCWHILE @@fetch_status = 0BEGINSET QUOTED_IDENTIFIER ONDELETE FROM TBLDEPOBKMIKTAR WHERE DEPOBKINC=@DEPOBKINCAND OWNERINC = @inc AND ISLEMID=2 AND HAREKETID=19 AND BIRIM=1SET QUOTED_IDENTIFIER OFFPRINT @DEPOBKINCFETCH NEXT FROM Miktar INTO @dblid,@inc,@DEPOBKINCENDCLOSE MiktarDEALLOCATE MiktarENDEND
I am currently running the following query from Query Analyser, I am connected to Server_A and inserting records into Server_B.Database_B.dbo.MyTable from Server_A .Database_A.dbo.TableRef
Insert into Server_B.Database_B.dbo.MyTable(Field1,Field2,Field3) Select Field1_Ref,
Field2_Ref, Field3_Ref from Server_A .Database_A.dbo.TableRef
However Server_B.Database_B.dbo.MyTable is referenced within an Indexed View and whenever I run this query I get the following error:
Msg 1934, Level 16, State 1, Line 1
INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.
I have tried setting ARITHABORT to ON & OFF within the Query and within the database properties but still recieve the same error.
Does anyone have any ideas on why this would not work?
Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."error after creating a view.We wanted a composite unique constraint that ignored nulls, so we setup a view using the following script:/* --- start --- */BEGIN TRANSACTIONSET QUOTED_IDENTIFIER ONSET ARITHABORT ONSET NUMERIC_ROUNDABORT OFFSET CONCAT_NULL_YIELDS_NULL ONSET ANSI_NULLS ONSET ANSI_PADDING ONSET ANSI_WARNINGS ONCOMMITGOCREATE VIEW vw_MyViewWITH SCHEMABINDINGASSELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULLGO/* --- end --- */and then added the constraint to the new view/* --- start --- */CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ONvw_MyView(Col1, Col2)GO/* --- end --- */I thought we were doing fine, 'til we started running some DELETEstored procedures and got the above error. The error also citedARITHABORT as an incorrect setting until we ran this script:/* --- start --- */USE masterDECLARE @value intSELECT @value = value FROM syscurconfigsWHERE config = 1534SET @value = @value | 64EXEC sp_configure 'user options', @valueRECONFIGURE/* --- end --- */TIA to anyone kind enough to shed some light on this for me. Is theresomething we should have done differently in creating the view andindex? If not, what's the procedure for working through thesesettings errors?I've read through some other threads on this subject, but didn'treally find what I was looking for. Thanks again for any help. Wouldbe appreciated.-matt
I have tried many variations (after reviewing other posts) and can notresolve the following issue:RUNNING SQL MAINTENANCE----------------------------SET ARITHABORT ONSET CONCAT_NULL_YIELDS_NULL ONSET QUOTED_IDENTIFIER ONSET ANSI_NULLS ONSET ANSI_PADDING ONSET ANSI_WARNINGS ONSET NUMERIC_ROUNDABORT OFFexec master..xp_sqlmaint '-D SBC -UpdOptiStats 10 -RebldIdx 10'--tried UpdOptiStats and RebldIdx separately with same resultsRECEIVE THE FOLLOWING MESSAGE------------------------------[Microsoft SQL-DMO (ODBC SQLState: 42000)]Error 1934: [Microsoft][ODBC SQL Server Driver][SQL Server]UPDATE STATISTICS failed because the following SET options haveincorrect settings: 'QUOTED_IDENTIFIER, ARITHABORTSERVER SETUP-------------------------------Windows 2000, Service Pack 4SQL Server 2000 Standard Edition, Service Pack 3Any help is greatly appreciated.
Hi,I am getting the following error when I run a stored procedure inwhich I am inserting/deleting data from a view that selects from aremote table.INSERT failed because the following SET options have incorrectsettings: 'ARITHABORT'The first statement in the stored procedure is 'set arithabort on'. Ialso ran 'set arithabort on' before creating the view.I read many articles ragarding the setting of arithabort. I set it forthe connection, for the database (alter database) and above all forthe server (sp_configure) but could not get around the above error.However, when I had made the setting using "sp_configure 'useroptions', 64" I was able to run the stored procedure successfully acouple of times. But, later when I had resest 'user options' to 0 andthen back to 64 just to reproduce the earlier error and confirm thatthe error does not come with the 'user options' to 64 setting I wasgetting the same error.Is there any way by which I can overcome the problem?Thanks,Iqbal
I am trying to insert a row into a table using a stored procedure and Iget the following error if I try this from QA:INSERT failed because the following SET options have incorrectsettings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.If I try to run this from Microsoft Access, I get a slightly differenterror:INSERT failed because the following SET options have incorrectsettings: 'ANSI_NULLS., QUOTED_IDENTIFIER, ARITHABORT'.This is what I'm trying to run in QA:declare @P1 intset @P1=NULLexec stpAddNewDistributionMaster 142, 2, 'INTRODUCTION OF FILTERASSEMBLY', 0, 1, @P1 outputselect @P1===========================Here are the relevant definitions:TABLE:CREATE TABLE [dbo].[tblDistributionMaster] ([fldDistributionID] [int] IDENTITY (1, 1) NOT NULL ,[fldDocumentID] [int] NULL ,[fldDocumentType] [int] NULL ,[fldDocumentTitle] [varchar] (255) COLLATESQL_Latin1_General_CP1_CI_AS NULL ,[fldDocumentSiteID] [int] NULL ,[fldActive] [bit] NOT NULL) ON [PRIMARY]GOALTER TABLE [dbo].[tblDistributionMaster] WITH NOCHECK ADDCONSTRAINT [DF__Temporary__fldDo__2739D489] DEFAULT (0) FOR[fldDocumentID],CONSTRAINT [DF__Temporary__fldDo__282DF8C2] DEFAULT (0) FOR[fldDocumentType],CONSTRAINT [DF__Temporary__fldDo__29221CFB] DEFAULT (0) FOR[fldDocumentSiteID],CONSTRAINT [DF__Temporary__fldAc__2A164134] DEFAULT (1) FOR[fldActive],CONSTRAINT [aaaaatblDistributionMaster_PK] PRIMARY KEY NONCLUSTERED([fldDistributionID]) WITH FILLFACTOR = 90 ON [PRIMARY]GOCREATE INDEX [fldDistributionID] ON[dbo].[tblDistributionMaster]([fldDistributionID]) WITH FILLFACTOR =90 ON [PRIMARY]GOCREATE INDEX [fldDocumentID] ON[dbo].[tblDistributionMaster]([fldDocumentID]) WITH FILLFACTOR = 90 ON[PRIMARY]GOCREATE INDEX [fldDocumentSiteID] ON[dbo].[tblDistributionMaster]([fldDocumentSiteID]) WITH FILLFACTOR =90 ON [PRIMARY]GOCREATE INDEX [fldDocumentType] ON[dbo].[tblDistributionMaster]([fldDocumentType]) WITH FILLFACTOR = 90ON [PRIMARY]GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_1A_3A] ON[dbo].[tblDistributionMaster] ([fldDistributionID], [fldDocumentType])')GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_3A_1A] ON[dbo].[tblDistributionMaster] ([fldDocumentType], [fldDistributionID])')GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_2A_1A] ON[dbo].[tblDistributionMaster] ([fldDocumentID], [fldDistributionID]) ')GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_3A_2A] ON[dbo].[tblDistributionMaster] ([fldDocumentType], [fldDocumentID]) ')GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_2A_3A] ON[dbo].[tblDistributionMaster] ([fldDocumentID], [fldDocumentType]) ')GO/****** The index created by the following statement is for internaluse only. ******//****** It is not a real index but exists as statistics only. ******/if (@@microsoftversion > 0x07000000 )EXEC ('CREATE STATISTICS [hind_37575172_1A_2A_3A] ON[dbo].[tblDistributionMaster] ([fldDistributionID], [fldDocumentID],[fldDocumentType]) ')GOSET QUOTED_IDENTIFIER ONGOSET ANSI_NULLS ONGOCREATE TRIGGER "tblDistributionMaster_UTrig" ONdbo.tblDistributionMaster FOR UPDATE ASSET NOCOUNT ON/* * PREVENT UPDATES IF DEPENDENT RECORDS IN 'tblJobs' */IF UPDATE(fldDistributionID)BEGINIF (SELECT COUNT(*) FROM deleted, tblJobs WHERE(deleted.fldDistributionID = tblJobs.fldDistributionID)) > 0BEGINRAISERROR 44446 'The record can''t be deleted orchanged. Since related records exist in table ''tblJobs'', referentialintegrity rules would be violated.'ROLLBACK TRANSACTIONENDENDGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_NULLS ONGOCREATE TRIGGER "tblDistributionMaster_DTrig" ONdbo.tblDistributionMaster FOR DELETE ASSET NOCOUNT ON/* * CASCADE DELETES TO 'tblJobs' */DELETE tblJobs FROM deleted, tblJobs WHERE deleted.fldDistributionID =tblJobs.fldDistributionIDGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO===========================SPROC:CREATE PROCEDURE stpAddNewDistributionMaster@DocumentID int,@DocumentType int,@Title varchar(255),@SiteID int,@Active bit,@DistributionID int OUTPUTASINSERT INTO tblDistributionMaster(fldDocumentID,fldDocumentType,fldDocumentTitle,fldActive,fldDocumentSiteID)VALUES(@DocumentID,@DocumentType,@Title,@Active,@SiteID)SET @DistributionID = IDENT_CURRENT('tblDistributionMaster')GO==============================Thanks in advanceEdward
I am getting the following error message: [-E-19:42] Message: SELECT failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.
I am using the following set options before the sp is created:
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET NUMERIC_ROUNDABORT OFF
I looked on the internet and most of solutions were related to indexed views or computed columns. But I am neither using any indexed views nor computed columns. Also the same sp is working fine in one environment but giving the above error in another SQL server. I am using SQL Server 2005 with SP1.
Please help me in finding the cause & the resolution for this issue.
I'm updating one column using trigger but i am getting below error .
UPDATE failed because the following SET options have incorrect settings: 'NUMERIC_ROUNDABORT'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
As noted on the msdn the ANSI_NULLS for a stored procedure are set at time off creation (http://msdn.microsoft.com/en-us/library/aa259229(SQL.80).aspx).
Using: - SQL server 2000
My question is; How do i get the details of a sp and display the ANSI_NULLS setting for it. ("select * from information_schema.routines" doesnt shows this information)
I have an application running against a SQLServer 2005 Express. For some limitations, I had to access from the same application to another database, but I cannot change to another server.
So I have 2 created a second instances, where the first one refers the second one and I created synonyms in the first one to access to all the objects in the second one, to emulate a database in the first instances, but running on the second one. The final idea is to move to another server, but for the testing I use another instance.
But when I try to access to the aplication database, I hav the following error: 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.
I searched solutions for this issue, but I only found to add SET ANSI_NULLS ON and SET ANSI_WARNINGS ON to my connection, before the queries, but I can't, because I cannot change the application.
I have a SQL200 stored proc that gives me the error "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." when I try to execute it through the query analyzer.
I was able to create the stored proc fine but when I try to execute it through the query analyzer it gives me the above error. I do have Link Server select inside the stored proc. I have to turn of warnings inside the stored proc in order for it to not crash my vb6 recordset by putting in the SET ANSI_WARNINGS OFF SET NOCOUNT OFF SET ANSI_NULLS OFF or else my vb6 recordset crashes.
When I created the sproc, I did what every one was telling me to do in the forums by putting in the
SET ANSI_WARNINGS ON Go SET NOCOUNT ON GO SET ANSI_NULLS ON GO
CREATE Procedure usp_SprocName
AS SET ANSI_WARNINGS OFF SET NOCOUNT OFF SET ANSI_NULLS OFF
INSERT [DELETE] failed because the following SET options have incorrect settings: 'ARITHABORT'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods. On local dev machine with SQL Express DB everything works fine. Once moved to shared hosting environment (with adjustments to web.config), insert and delete stored procedures produce the above error. Made sure that stored procedures SET ARITHABORT ON at the beginning and OFF at the end, without success. Even SET ARITHABORT ON at DB level without success. Suggestions appreciated
In SQL 2000, working with Maintenance plan wizard, what would be best settings and values should i choose in "Update Data Optimization information" window,
I get the following error when running a report in report builder using the Adventureworks sample model: Semantic query execution failed. Incorrect syntax near 'NULLAND'.----------------------------Query execution failed for data set 'dataSet'.----------------------------An error has occurred during report processing.
Here is how to replicate the error:
Create a table report using the Adventure Works model. Select Product entity, add Product Category and #Products to the table. Edit formula for #Products to "COUNT(Products)" and add a filter on Products for "Discontinued Date is empty". (I want a count of products that have not been discontinued). If you run the report now, it willl work as expected. Add a report filter for "Product.Color is empty" (I only want to see products that don't have a color) Run the report to get the above error. While the above is a contrived example, I am getting the same error on a data model that I am developing for a customer.
Am I missing something, or is this a bug in Report Builder?
I can select the tables and fields, but when I click on Advanced the Check Box to Create the Commands is not available. they are dimmed out. Why is this happening, is it a setting that I have missed. Any help is appreciated.
Hi all My error is as follows: Incorrect syntax near '('.Line 27: acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer)Line 28: acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id)Line 29: acceptOrDeclineFriendship.Update()Line 30: Line 31: End Sub Bear with me... I have a page where i use a repeater control to list users who have requested to be friends with the currently online user. The 'getFriendRequests' query looks like this: SelectCommand="SELECT * FROM Friends, UserDetails WHERE (Friends.UserID = UserDetails.UserID) AND (FriendID = @UserID) AND (ApprovedByFriend = 'False') ORDER BY Friends.Requested DESC">This works. Within each repeater template, there are 2 buttons, 'Accept' or 'Decline', like this: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="getFriendRequests"> <ItemTemplate> (other stuff like avatar and username etc) <asp:Button ID="accept" runat="server" Text="Accept" commandName="Accept" commandArgument='<%#Eval("UserID")%>' onCommand="Accept_Decline_Friends"/> <asp:Button ID="decline" runat="server" Text="Decline" commandName="Decline" commandArgument='<%#Eval("UserID")%>' onCommand="Accept_Decline_Friends"/> </ItemTemplate> </asp:Repeater> The code-behind (VB) which deals with this is as follows: Protected Sub Accept_Decline_Friends(ByVal sender As Object, ByVal e As CommandEventArgs)
'retrieve id of requestee and the answer accept/decline Dim friend_id As String = e.CommandArgument.ToString Dim answer As String = e.CommandName.ToString
'add the parameters acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer) acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id) acceptOrDeclineFriendship.Update()
End Sub Since the buttons are being created dynamically, this is how i track 1. the response from the currently logged in user 'Accept/Decline' and 2. who they are responding to (by their uniqueid) This relates to a sqlDataSource on my .aspx page like this: <!---- update query when user has accepted the friendship ----> <asp:SqlDataSource ID="acceptOrDeclineFriendship" runat="server" ConnectionString="<%$ xxx %>" UpdateCommand="UPDATE Friends SET (ApprovedByFriend = @Response) WHERE (FriendID = @UserID) AND (UserID = @FriendID)"> <UpdateParameters> <asp:ControlParameter Name="UserID" ControlID="userIdValue" /> </UpdateParameters> </asp:SqlDataSource> Which is meant to update my 'Friends' table to show that 'ApprovedByFriend' (the logged in user) is either 'Accept' or 'Decline', and record who's request was responded to. I hope this is clear, just trying to suppy all of the information! The error appears to be saying that I have an issue with my code-behind, where i am telling the sqlDataSource above to UPDATE. What I can say is that for each button in the repeater, the 2 variables 'friend_id' and 'answer' are picking up the correct values. Can anyone see any obvious problems here? Any help is very much appreciated as i am well and truley stuck!
Please let me know what is wrong with my code below. I keep getting the "Incorrect syntax near 'UpdateInfoByAccountAndFullName'." error when I execute cmd.executenonquery. I highlighted the part that errors out. Thanks a lot. --------------------------------------------------------------------------------------------------------------------------- public bool Update( string newaccount, string newfullname, string rep, string zip, string comment, string oldaccount, string oldfullname ) { SqlConnection cn = new SqlConnection(_connectionstring); SqlCommand cmd = new SqlCommand("UpdateInfoByAccountAndFullName", cn); cmd.Parameters.AddWithValue("@newaccount", newaccount); cmd.Parameters.AddWithValue("@newfullname", newfullname); cmd.Parameters.AddWithValue("@rep", rep); cmd.Parameters.AddWithValue("@zip", zip); cmd.Parameters.AddWithValue("@comments", comment); cmd.Parameters.AddWithValue("@oldaccount", oldaccount); cmd.Parameters.AddWithValue("@oldfullname", oldfullname); using (cn) { cn.Open(); return cmd.ExecuteNonQuery() > 1; } }
I have a update trigger on a table which fires trapping the userid and time in the same record. The code is below. The tirgger only works if I have the recursive triggers option unchecked on databae properties. Is the way I am trying the only way to accomplish this in the update trigger or is there an more efficient way. Thanks
CREATE trigger tr_cmsUpdt_MARS on dbo.PATIENT_MEDICATION_DISPERSAL_ for UPDATE as -- updates record with sql user and timestamp --created 11-28-00 tim cronin DECLARE @muser varchar(35), @rec_lock_status int, @ptacpt_status int set @muser = current_user begin UPDATE PATIENT_MEDICATION_DISPERSAL_ set MODIFIED_BY = @muser, MODIFIED_TS = getdate() from deleted dt WHERE PATIENT_MEDICATION_DISPERSAL_.RECORD_ID = dt.RECORD_ID end GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO
Hi, Here's the code I've used to try and update a new user's IP Address to a Table called Customer who's key field in the UserId: Getting the Exception Error "Incorrect Syntax near'('. " Any ideas? protected void ContinueButton_Click(object sender, EventArgs e) { //Get the ip address and put it into the customer table - (the instance of this user now exists)
MembershipUser _membershipUser = Membership.GetUser(); //This gets the active user if there is someone logged in... Guid UserId = (Guid)_membershipUser.ProviderUserKey; //This gets the userId for the currently logged in user string IPAddress = Request.UserHostAddress.ToString();//This gets the IPAddress of the currently logged in user string cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); using (System.Data.SqlClient.SqlConnection con =new System.Data.SqlClient.SqlConnection(cs)) { con.Open(); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text;
Hi, I figure that my query below should return the records that I've inserted into test1 and test2 after I turn ansi_nulls off for my session. But the query does not return any records. Any ideas?
create table test1 (id int, create_date datetime null) create table test2 (id int, create_date datetime null)
does anyone know how to keep QA from adding the lines setting thesetwo options on and off along with blank lines at the beginning and endof every object you edit? i have searched quite a bit on this buthaven't been able to come up with anything.
Hi All,I'm converting some stored procs from Sybase to SQL Server, and I'mhaving serious problems with Null comparisons.When I run the code below on Sybase, it returns both rows. When I runit on MS SQL Server, it returns nothing. I have set ANSI_NULLS off inthe code (and on the session through Query Analyzer), but it doesn'tseem to make any difference. Am I missing something?---------------set ANSI_NULLS offdrop table #TestNullcreate table #TestNull (Field1 varchar(10), Field2 varchar(10))insert into #TestNull values (1, null)insert into #TestNull values (1,1)declare @TestVar varchar(10)select @TestVar = Nullselect * from #TestNull where Field1 = @TestVar---------------Thanks in advance,Saul
Is there any way via T-SQL to run through a database and ensure that QUOTED_IDENTIFIER and ANSI_NULLS is set for all stored procs and functions etc on a database without having to recreate every proc / fn ?
The reason this is an issue is I'm trying to take advantage of indexed views to get a performance increase in an application - but not all of the procs/fn's have historically been created with ANSI_NULLS and QUOTED_IDENTIFIER set - so any proc that's not set correctly will fail once the indexed view has been created.
I could I suppose, script out all the procs / functions and do a bit of search and replace to ensure that these are set correctly by recreating all procs and functions - but I'm trying to avoid doing that as I've over 500 databases to upgrade - a metadata hack may be preferable.
Thoughts or comments or possible alternative approaches are welcome...
Im having trouble accessing a linked/remote server from a powerbuilder app.
I can run the stored proc from QueryAnalyzer, but from the app I get the error message - 'heterogenous query must have ANSI_NULLS set option ON, set it and retry'.
Is the ANSI_NULLS option set for each db, or each server? And how can I check a DB or Server to see what the setting for ANSI_NULLS is? Does the local and remote/linked server/db need this option ON?
Any idea why this remote query works form QA but not from an application?
DECLARE @a varchar(100) SET @a = @FailedRegionServerName + '.Ithalat.dbo.Product'
DECLARE @s varchar(100) SET @s = ' SELECT * FROM ' + @a EXEC ( @s )
When I execute it I get the error:
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.
Then I put SET ANSI_WARNINGS ON SET ANSI_NULLS ON lines into the procedure. Also checked "Ansi Nulls" and "Ansi Warnings" in the properties of SQL Server. It didn't work
Then I tried:
DECLARE @s varchar(300) SET @s = 'SET ANSI_WARNINGS ON; SET ANSI_NULLS ON; SELECT * FROM ' + @a EXEC ( @s )
I still got the error.
WHAT SHOULD I DO? HOW CAN I GET A TABLE CONTENT FROM A LINKED SERVER? Any will be appreciated, thanks a lot...
I have a Stored Procedure I am trying to run that joins to a remote database. I am able to see everything in the QA just fine with this (courtesy of Anatha):
SELECT DISTINCT a.* FROM LOCATION a, LinkServer.MC_Card.webuser.LOCATION b WHERE a.location_number = b.location_number
But I am trying to run this query in Stored Procedure(notice the 4-part name callout to the LinkedServer tables) which returns the error message:
Error 7405: Heterogeneous queries require 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.
Here is the Stored Procedure: /****** Object: Stored Procedure dbo.spELRMCcardXtionByDate Script Date: 4/24/2001 11:51:27 AM ******/
CREATE PROCEDURE dbo.spELRMCcardXtionByDate @dcid nvarchar(255), @startDate datetime, @endDate datetime AS -- declare @dcid nvarchar(255) -- set @dcid = '1032' SELECT STORE.[Str#], STORE.[Dcid#], E.card_number, E.program_number , E.start_date, E.end_date, E.card_number, E.event_number , E.status, E.budget, E.scheduled_date, P.tx_time, P.purchase_amount , L.merchant_name FROM (STORE INNER JOIN LinkServer.MC_Card.webuser.EVENT E ON STORE.[DemoID#] = E.event_number) LEFT JOIN (LinkServer.MC_Card.webuser.LOCATION L RIGHT JOIN LinkServer.MC_Card.webuser.POS_TX P ON L.location_number = P.location_number) ON E.event_number = P.event_number WHERE (((STORE.[Dcid#])= @dcid)) AND E.scheduled_date BETWEEN @startDate AND @endDate ORDER BY STORE.[Str#] -- and E.card_number IS NOT NULL GO
I am trying to create a stored procedure that updates a table on another server. It give the me the error about requiring ANSI_NULLS and WARNINGS being set. How can I set these if they are not already set? I tried setting them within the stored procedure, but does not appear to be working. Unless I am doing something wrong. I am trying to add SET ANSI_NULLS ON and doing the same thing for WARNINGS. Any thougts or suggestion on what to do? Thanks for the help
I'm using the SQL Native Client to connect my VB6 application to my SQL Server 2005 database. My SQL Server 2005 database has ANSI_NULLS turned off. I have a query embedded in my VB6 application that uses the syntax "fieldName = NULL" in the WHERE clause. When I execute the query via the SQL Native Client, the query returns zero rows. When I execute the same query via the old OLEDB driver, the query returns many rows. If I change my query to "fieldName IS NULL" syntax, the problem goes away. However, I am more interested in figuring out why ANSI_NULLS are turned on when using the SQL Native Client even though my database has them turned off. Is there a connection string property that I can use with the SQL Native Client to ensure that the query is executed with ANSI_NULLS off?
When I perform a query on a linked Oracle server in the Query analyser Ihave noprboblem' to perform this query.However, when I create this query in a stored procedure I get a compilationerrorwhen saving this procedure. (Not when compiling; it has no errors)Server: Msg 7405, Level 16, State 1, Line 1Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS optionsto be set for the connection. This ensures consistent query semantics.Enable these options and then reissue your query.When I create a dynamic SQL statement then I can save this stored procedurewhen I run the stored procedure this same error happens.What do I have to do.Arno de Jong, The Netherlands