[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

STORED procedure paramters delete

Posted on 2011-03-17
1
Medium Priority
?
338 Views
Last Modified: 2012-05-11
In the following stored procedure BOTH images get deleted regardless of what is passed in for @ImageType.

Why
USE [Store]
GO
/****** Object:  StoredProcedure [dbo].[spDeleteImage]    Script Date: 03/17/2011 14:59:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spDeleteImage]
	-- Add the parameters for the stored procedure here
	@Product_ID		int,
	@ImageType      varchar(5)

AS


	SET NOCOUNT ON;
		
	IF @ImageType = 'main' 
		
		BEGIN
		declare @Product_Image int
		SELECT @Product_Image = Product_Image FROM Products WHERE Product_ID= @Product_ID	
		
		UPDATE Products SET Product_Image = null WHERE Product_ID = @Product_Image
		DELETE FROM Images WHERE  Image_ID = @Product_Image
		
	END
	
	IF @ImageType = 'thumb' 
		
		BEGIN
		
		DECLARE @Product_Thumb int
		SELECT @Product_Thumb = Product_Thumb FROM Products WHERE Product_ID = @Product_ID
		UPDATE ProductS SET Product_Thumb = null WHERE Product_Thumb = @Product_ID	
		
		DELETE FROM Images WHERE  Image_ID = @Product_Thumb
		
	END

Open in new window

0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35161214
that is not possible.
you properly have coded the IF with BEGIN / END , so you must be looking at the code in another procedure / database than where you are actually running it.
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question