Hi,
I am trying to write a stored procedure that does some simple math. All I want to do is
get a views number with a select and then increment +1, and then do an update with the new value.
Here is my stored procedure so far. looks like it's something simple I am missing
any help would be greatly appreciated
I am trying to write a stored procedure that does some simple math. All I want to do is
get a views number with a select and then increment +1, and then do an update with the new value.
Here is my stored procedure so far. looks like it's something simple I am missing
Code:
/****** Object: StoredProcedure [dbo].[UpdateAquariumViews] Script Date: 10/17/2010 23:51:05 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[UpdateAquariumViews]( @AquariumsID int ) AS Declare @AquariumViews int /* problem seems to be here, not getting @AquariumViews value */ Select *,@AquariumViews from Aquariums WHERE (AquariumsID = @AquariumsID ) SET @AquariumViews = @AquariumViews + 1 Update Aquariums SET AquariumViews = @AquariumViews WHERE (AquariumsID = @AquariumsID )
Comment