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 2000 Forums
 Transact-SQL (2000)
 Update a Counter in a stored Proc....

Author  Topic 

interclubs
Yak Posting Veteran

63 Posts

Posted - 2003-01-05 : 21:50:37
The following stored procedure keeps giving me errors, telling me that I can't use a column name in the statement...I know it should be simple, anyone have any ideas? I am just trying to update the column 'clicked' by one every time the stored proc. runs and return the 'LinkURL'.

CREATE PROCEDURE LM_Clicked
@MessageID int
AS
Declare @ID int

BEGIN TRAN

Insert Into LM_Links(Clicked, LastClick)
Values(Clicked+1, GetDate) where MessageID=@MessageID
Select @ID=@@IDENTITY
Select LinkURL from LM_Links where ID = @ID

IF @@ERROR>0
Rollback Tran

COMMIT TRAN
RETURN

Thanks Guys!


jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-01-05 : 22:25:46
I think you want to UPDATE, instead of INSERT ???

quote:

I am just trying to update the column 'clicked' by one every time the stored proc. runs and return the 'LinkURL'.



If not, maybe


Insert Into LM_Links(Clicked, LastClick)
SELECT Clicked+1, GetDate()
FROM LM_Links

WHERE MessageID=@MessageID

Select @ID=@@IDENTITY
Select LinkURL from LM_Links where ID = @ID


- Jeff
Go to Top of Page

interclubs
Yak Posting Veteran

63 Posts

Posted - 2003-01-05 : 23:01:06
Been a long weekend! Yeah, it was supposed to be an update, which was the prob. Thanks!

Go to Top of Page
   

- Advertisement -