troubleshooting Question

What is wrong with the SQL syntax

Avatar of TECH_NET
TECH_NET asked on
Microsoft SQL Server 2005
12 Comments1 Solution198 ViewsLast Modified:
I am having the following SQL Query that basically  the calculate the sum of a column SOLUTION_TYPE_ID from the database. and add a 1 to the fetched result if the ACTION_ID parameter is 1 and substract 1 if the ACTION_ID parameter is 2.


CREATE PROCEDURE [dbo].[MarkSolutionType]
(
 	@SOLUTION_TYPE_ID int,
	@IP_ADDRESS varchar(50),
	@ACTION int,
	@ID int
)
AS
SET NOCOUNT OFF;
 
 
 
IF ACTION_ID=1 
	UPDATE EW_INTERVIEW_QUESTIONS_RESPONSES
	SET
		SOLUTION_TYPE_ID=SELECT SUM(SOLUTION_TYPE_ID)+1 FROM EW_INTERVIEW_QUESTIONS_RESPONSES WHERE ID=@ID,
		IP_ADDRESS=@IP_ADDRESS,
		UPDATE_DATE=getdate()
 
	WHERE
	ID=@ID
 
ELSE
	UPDATE EW_INTERVIEW_QUESTIONS_RESPONSES
	SET
		SOLUTION_TYPE_ID=SELECT SUM(SOLUTION_TYPE_ID)-1 FROM EW_INTERVIEW_QUESTIONS_RESPONSES WHERE ID=@ID,
		IP_ADDRESS=@IP_ADDRESS,
		UPDATE_DATE=getdate()
 
	WHERE
	ID=@ID
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros