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 6: Common Problems with Data Integrity) ;GOINSERT INTO dbo.Items(ItemLabel,BoxLabel,WeightInPounds,Barcode)VALUES ('Sleeping Mat','Camping Gear',1,NULL) ;Listing 6-29: The CHECK constraint UNQ_Items_Barcode allows us to insert morethan one row with a NULL barcode.Listing 6-30 verifies that we can INSERT items with NOT NULL barcodes, as long as wedo not INSERT duplicates.INSERT INTO dbo.Items(ItemLabel,BoxLabel,WeightInPounds,Barcode)VALUES ('Big Flashlight','Camping Gear',2,'12345678') ;GO182

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

Saved successfully!

Ooh no, something went wrong!