Wrox Programmer Forums
BOOK: Professional Microsoft SQL Server 2008 Programming
This is the forum to discuss the Wrox book Professional Microsoft SQL Server 2008 Programming by Robert Vieira; ISBN: 9780470257029
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Microsoft SQL Server 2008 Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 7th, 2010, 03:31 PM
Registered User
Join Date: Jul 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Post Bad Trigger Pg. 381

When I read through the delete portion of the INSERT, DELETE trigger DocumentBelongsToProduct I couldn't help but think, "that thing is whacky." Then I deleted a record like it shows in the book and it re-set every flag in the Production.Product table back to 0. Basically, the T-SQL on that portion is not right. The correct code to get that part working, at least in my minimal testing is this
SELECT @Count = COUNT(*) FROM Deleted
	IF @Count > 0
			SET p.InformationFlag = 0
			FROM Deleted d
			JOIN Production.Product p
				ON d.ProductID = p.ProductID
Put that in there instead of what's printed, and you can delete a record from the Production.ProductDocument and only that record will get the flag dropped off in the Production.Product table.

Donny Buckman

Similar Threads
Thread Thread Starter Forum Replies Last Post
bad editing econophil BOOK: Beginning JavaScript 4th Edition 4 July 6th, 2010 05:30 PM
Bad Connection String paulcbyrum Access VBA 3 May 9th, 2008 09:19 PM
Why session_register() is bad. nikolai Pro PHP 17 November 21st, 2004 09:35 PM
Bad Codes from Chapter 3 and on, Please Help! GraphicArmy BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 15 May 3rd, 2004 05:07 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.