Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 .Net Scheduled Task giving SQL error

Author  Topic 

eljapo4
Posting Yak Master

100 Posts

Posted - 2011-01-17 : 05:37:54
Hi, I've developed a simple scheduled task that executes a Stored procedure. When I run the task in debug mode the application writes out the following error message: "17/01/2011 10:11:36,modFunctions,GetData,5,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."
BUT if i execute the Sp from within SQL itself it runs no problems. Here's the SQL code:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/*

EXEC mp_whsStockWatch_viewsWTableMTS2BKUP
# Updated: 22/12/2010 - Because mp_whsStockWatchMTS2BKUP has a computed coulmn added I've had to add SET ARITHABORT ON
*/

ALTER PROCEDURE [dbo].[mp_whsStockWatch_viewsWTableMTS2BKUP]

AS

SET ARITHABORT ON

BEGIN

INSERT INTO mp_whsStockWatchMTS2BKUP
SELECT MAX(Category1) AS Category1,
Region,
Site,
Area,
MAX(Category2) AS Category2,
MAX(COALESCE(Category3, 'NULL')) AS Category3,
MAX(COALESCE(Category7, 'NULL')) AS Category7,
Resource,
MAX(COALESCE(Description, 'NULL')) AS Description,
SUM(Quantity) AS Quantity,
MAX(UM) AS UM,
SUM(EURValue) AS EURValue,
SUM(GBPValue) AS GBPValue,
MAX(Price) AS Price,
MAX(Currency) AS Currency,
QAStatus,
Days,
CAST(CONVERT(DATETIME,GETDATE(),105) AS VARCHAR(35)) AS CurrDate,
Age
FROM mp_whsStockWatchVw1
GROUP BY Region,
Site,
Area,
Resource,
UM,
QAStatus,
Days,
Age
ORDER BY Category1

END

GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

Any ideas why the app can't execute the SP?

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-01-17 : 07:31:45
See if this thread is of any help:

http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/d24f7e32-4632-484c-8c58-c194837fbd71/

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

eljapo4
Posting Yak Master

100 Posts

Posted - 2011-01-17 : 08:38:09
Lumbago thanks for that - some useful hints on that site and one bit of advice to change the DB properties:
Right click [Database_B]-->Properties-->Options-->Other Options-->Misscellaneous-->Arithmetic Abort Enabled -->true

seems to have worked for me
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-01-17 : 09:15:40
Great that it worked out for you. And remember: Google is your friend! It took me roughly 15 seconds to find the link by searching for "INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'"

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -