Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 10:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.