DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to setup a restaurant inventory check constraint?

The following Microsoft SQL Server T-SQL code sample illustrates how to setup a table level constraint for a restaurant database:

-- Create constraint

ALTER TABLE dbo.RestaurantInventory

WITH NOCHECK ADD CONSTRAINT CK_RestaurantInventory_Type_Cost

CHECK ( (TYPE = 'Food'

 AND COST < (100)

  OR TYPE = 'Furniture'

     AND COST > (10)

     AND COST < (1000)) )

GO

 

-- Enable constraint

ALTER TABLE dbo.RestaurantInventory

 CHECK CONSTRAINT CK_RestaurantInventory_Type_Cost

GO

This constraint checks the range of cost for food items and restaurant furniture.

Related article:

Creating and Modifying CHECK Constraints

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE