creating a table in sql 2008 with a default value and constraint

Hello experts I have a table I am trying to create and I need a default value of 0 in the dues column and the I need to make sure only positive values can go in that column

below is my code
Please help
USE Membership

Create table Groups
( GroupID INT NOT NULL PRIMARY KEY,
 GroupName Varchar(20) NOT NULL,
Dues Money NOT NULL)

Open in new window

HawaiiDragonAsked:
Who is Participating?
 
Patrick MatthewsConnect With a Mentor Commented:
HawaiiDragon,

A default value of zero and a constraint of only positive values are inconsistent.

Zero is neither positive nor negative.

Patrick
0
 
HawaiiDragonAuthor Commented:
Okay I got the default value part figued out but I need to make sure that the column will only take number >0 . Below is my updated code
USE Membership

Create table Groups
( GroupID INT NOT NULL PRIMARY KEY,
 GroupName Varchar(20) NOT NULL,
Dues Money NOT NULL DEFAULT '0' 
)

Open in new window

0
 
HawaiiDragonAuthor Commented:
Okay I figured it out myself thanx for your help

USE Membership

Create table Groups
( GroupID INT NOT NULL PRIMARY KEY,
 GroupName Varchar(20) NOT NULL,
Dues Money NOT NULL DEFAULT '0'
CHECK (Dues>=0)
)
0
 
HawaiiDragonAuthor Commented:
thanx for your explanation it pointed me in the right direction.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.