troubleshooting Question

T-SQL Debugging

Avatar of vcbertini
vcbertiniFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2005
10 Comments2 Solutions195 ViewsLast Modified:
I have a stored procedure that does not seem to be working. I have verified that the record exists in the database. I have a feeling that there is some procedural problem I am overlooking, but after hours, I have not been able to find it. HELP.

I am sending in the following parameters:
@ID = 2140
@action = 'S'  (although I really don't need to send this in because it is the default)

I am not sending any other parameters because they are not applicable.  Unfortunately I don't have the means to debug this (unless anyone can recommend a good freeware T-SQL debugger)
@type nchar(2) = 'X',
	   @ID int = 0,
	   @action nchar(2) = 'S',
	   @semester nchar(40) = null
	  
AS
BEGIN

if @action = 'I'
INSERT INTO Advisors
           ([semester])
           
     	VALUES
          (@semester)

ELSE IF @action = 'U'

	UPDATE	Advisors
	SET		semester = @semester		
	WHERE		ID = @ID

ELSE IF @action = 'D'

	DELETE FROM Advisors WHERE ID = @ID

ELSE IF @action = 'S'
	IF @ID = 0
		IF @type = 'X'
			SELECT * FROM Advisors
			WHERE (semester = @semester)
			ORDER BY lname, fname
		ELSE IF @type = 'A'
			SELECT * FROM Advisors
			WHERE (semester = @semester) AND approved = 1
			ORDER BY lname, fname
		ELSE IF @type = 'P'
			SELECT * FROM Advisors
			WHERE (semester = @semester) AND approved = 0
			ORDER BY lname, fname		
	ELSE

		SELECT     *
		FROM         Advisors
		WHERE     (ID = @ID)

END
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 10 Comments.
Join the Community
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 2 Answers and 10 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