17.07.2015 Views

Defensive Database Programming - Red Gate Software

Defensive Database Programming - Red Gate Software

Defensive Database Programming - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: Advanced Use of ConstraintsWHERE TicketID = 1 ;UPDATE dbo.DevelopersSET DeveloperStatus = 'Vacation'WHERE DeveloperID = 1 ;-- we shall need the test data intact-- to use in other examples,-- so we roll the changes backROLLBACK ;Listing 7-12: Closing the ticket allows Justin to take a vacation.Alternatively, we can assign the ticket to another developer.BEGIN TRANSACTION ;INSERT INTO dbo.Developers( DeveloperID ,FirstName ,Lastname ,DeveloperStatus)VALUES ( 2 ,'Peter' ,'Yang' ,'Active') ;UPDATE dbo.TicketsSET AssignedToDeveloperID = 2WHERE TicketID = 1 ;UPDATE dbo.DevelopersSET DeveloperStatus = 'Vacation'WHERE DeveloperID = 1 ;219

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!