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
 SQL Server Development (2000)
 Reusing a stored procedure for mutiple columns

Author  Topic 

taylo
Yak Posting Veteran

82 Posts

Posted - 2000-11-12 : 19:45:33
I am able to do this for selecting records but when trying to update or insert I get stuck. I want to use this same procedure to update several fields in the same table. Not all at once but 1 by 1. It is for a quiz where an answer is given for each page.
I can not get the syntax correct. Any clues?

CREATE PROCEDURE SP_QuizAnswers

@ID numeric(10),
@q nvarchar(10),
@ans nvarchar(10)

AS

UPDATE Quiz set

CASE @q
When 'Q1' then Q1
When 'Q2' then Q2
When 'Q3' then Q3

End

= @ans WHERE UserID = @ID

   

- Advertisement -