FireFox
FireFox

Reputation: 470

Stored Procedure with update statement not functioning

I have created a very simple stored procedure and verified that the query that needs to be executed is a correct/running query. Yet, once stored in the SP, it does not do anything apart from returning '0':

USE [test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[GenerateVolume] 

AS
BEGIN

    SET NOCOUNT ON;

    UPDATE test.dbo.[c500 CP_Simulation]
set GeneratedVolume = AvgFillRatePerDayPerCP +[dbo].[fn_InvsNorm](RAND(convert(varbinary, newid()))) * StDevFillRatePerDayPerCP
where test.dbo.[c500 CP_Simulation].OrgVPnr = test.dbo.[c500 CP_Simulation].OrgVPnr


END

No errors are given... Please give me a tip :)

Upvotes: 0

Views: 318

Answers (1)

nunespascal
nunespascal

Reputation: 17724

When you use the

SET NOCOUNT ON

It will suppress the "xx rows affected" message.

If your query works fine, your rows are getting updated. Since you have told sql server not to count how many rows were updated, you will not be told how many rows got updated.

Hope that clears some doubt.

Upvotes: 2

Related Questions