User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 401,732 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,188 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 1821 | Replies: 1
Reply
Join Date: Aug 2005
Location: El Paso, TX
Posts: 225
Reputation: extofer is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
extofer's Avatar
extofer extofer is offline Offline
Posting Whiz in Training

Help Field Constraint (don't want negative numbers)

  #1  
Apr 11th, 2006
I have a MS SQL DB where I need to add a constraint to a filed of a table. This table is manipulated through an application... in a particular field, the integer (field data type) is subtracted from 5 to 4 or 3 whatever, sometimes a user does an error and subracts 3 from 1, then the field becomes -2. I want to have a contraint on the field so there the integer will not go below 0. How can I make that possible??

Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Field Constraint (don't want negative numbers)

  #2  
Apr 14th, 2006
ALTER TABLE TableName
ADD CONSTRAINT
ConstraintName
CHECK
(FieldName >= 0)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 9:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC