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 Constraints-- we shall need the test data intact-- to use in other examples,-- so we roll the changes backROLLBACK ;Listing 7-13: Reassigning an active ticket.Also we need to verify that our system works when we modify Developers.DeveloperID column, as shown in Listing 7-14.BEGIN TRANSACTION ;PRINT 'Original Data in Tickets table' ;SELECT TicketID ,AssignedToDeveloperID ,DeveloperStatusFROM dbo.Tickets ;UPDATE dbo.DevelopersSET DeveloperID = -1WHERE DeveloperID = 1 ;PRINT 'Data in Tickets table after DeveloperID was modified';SELECT TicketID ,AssignedToDeveloperID ,DeveloperStatusFROM dbo.Tickets ;ROLLBACK ;Original Data in Tickets tableTicketID AssignedToDeveloperID DeveloperStatus----------- --------------------- ---------------1 1 Active220

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

Saved successfully!

Ooh no, something went wrong!