---
title: "Panikfråga"
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/21350-panikfråga"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "Bendro"
published: "2001-01-25T14:22:00.000Z"
updated: "2001-01-25T14:27:00.000Z"
replies: 1
views: 223
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/databaser-sql/21350-panikfråga"
---

# Panikfråga

## #1 — Bendro, 2001-01-25T14:22Z

Sitter och pluggar SQL och har fått en uppgift. Har letat efter svaret i Transact-SQL hjälpen och även i den enda bok jag har tillgänglig men hittar det inte där.

Frågan är "Vad är en CHECK-constraint?"

Finns det någon som kan ge mig ett bra svar eller kan tala om för mig var jag skall leta vore jag evigt tacksam.

Permalänk: https://www.webforum.nu/p/21350

## #2 — @nders, 2001-01-25T14:27Z

hej!

kort kan man säga att du begränsar tillåtna värden i en kolumn.

nedan på engelska ur sql server 7.0 books on line.

mvh,

> CHECK constraints enforce domain integrity by limiting the values that are accepted by a column. They are similar to FOREIGN KEY constraints in that they control the values that are placed in a column. The difference is in how they determine which values are valid: FOREIGN KEY constraints get the list of valid values from another table, and CHECK constraints determine the valid values from a logical expression that is not based on data in another column. For example, it is possible to limit the range of values for a salary column by creating a CHECK constraint that allows only data that ranges from $15,000 to $100,000. This prevents salaries from being entered beyond the normal salary range. 
>
> You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE or FALSE based on the logical operators. For the previous example, the logical expression is:
>
> salary \>= 15000 AND salary \<= 100000  
>
> It is possible to apply multiple CHECK constraints to a single column. These are evaluated in the order in which they were created. It is also possible to apply a single CHECK constraint to multiple columns by creating it at the table level. For example, a multiple-column CHECK constraint can be used to confirm that any row with a country column value of USA also has a two-character value in the state column. This allows multiple conditions to be checked in one place.

Permalänk: https://www.webforum.nu/p/351710

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/21350-panikfråga
