Click here to Skip to main content
15,353,757 members

Comments by Member 11265547 (Top 11 by date)

Member 11265547 9-Feb-15 4:45am View
finally found out how to do it, yes there was a trigger (sorry wasn't aware there was one) so I added the update to the trigger and it works great now.

Thanks everyone for your help.
and sorry I'm fairly new to SQL but its part of my job now so I appreciate the help.
Member 11265547 9-Feb-15 3:08am View
The reason I need to change the code before I delete it is because it is causing problems with some software that imports into the database. it is importing the data into the deleted products when there is a duplicate product code instead of the non deleted products.
Member 11265547 6-Feb-15 11:23am View
this does work but I need it to do both things
Member 11265547 6-Feb-15 10:11am View
Ok so I tried changing the error message to see if it shows up when i try to delete a product with stock and it did so this is the right procedure!

so maybe i'm putting the code into the wrong part of the code where should I insert (UPDATE Product SET ProductCode = 'D_' + ProductCode WHERE ProductID = @ProductID) in to the procedure
Member 11265547 6-Feb-15 10:02am View
so 'DELETE FROM Product WHERE ProductID = @ProductID' would delete the product from the table completely?

I thought there was another procedure that handles what happens when a product is deleted but I've not found any yet still looking though, there's 716 to look through, loosing the will!
Member 11265547 6-Feb-15 9:49am View
I know the UPDATE works because I have used the same thing to change a batch of products
Member 11265547 6-Feb-15 9:41am View
I know its not working because when I search through the deleted products and the product code does not have the 'D_' prefix.
Member 11265547 6-Feb-15 9:39am View
Member 11265547 6-Feb-15 9:25am View
You may just have made me realized I've done something stupid, It looks like there may be a second procedure for deleting products because this one like you say does not update the 'delete' field.
I'm looking for another one now!
Member 11265547 6-Feb-15 9:21am View
yes it is a string
Member 11265547 6-Feb-15 9:09am View
sorry, the update doesn't happen but no error is thrown up!