Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How can i avaoid negative values in SQL?

How can i avaoid negative values in SQL?

Scheduled Pinned Locked Moved Database
questiondatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john kuruvila
    wrote on last edited by
    #1

    hi, What is the SQL querry for not having negative values in the table? thanks,jijo Jijo kuruvila software developer trivandrum

    C 1 Reply Last reply
    0
    • J john kuruvila

      hi, What is the SQL querry for not having negative values in the table? thanks,jijo Jijo kuruvila software developer trivandrum

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      john kuruvila wrote: What is the SQL querry for not having negative values in the table? When you create the table you set a constraint like this:

      CREATE TABLE cust_sample
      (
      cust_id int PRIMARY KEY,
      cust_name char(50),
      cust_address char(50),
      cust_credit_limit money,
      CONSTRAINT chk_id CHECK (cust_id BETWEEN 0 and 10000 )
      )

      If the table is already created you can use ALTER TABLE in order to add the constraint (See the SQL Help files for how to use ALTER TABLE) Does this help?


      Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

      J 1 Reply Last reply
      0
      • C Colin Angus Mackay

        john kuruvila wrote: What is the SQL querry for not having negative values in the table? When you create the table you set a constraint like this:

        CREATE TABLE cust_sample
        (
        cust_id int PRIMARY KEY,
        cust_name char(50),
        cust_address char(50),
        cust_credit_limit money,
        CONSTRAINT chk_id CHECK (cust_id BETWEEN 0 and 10000 )
        )

        If the table is already created you can use ALTER TABLE in order to add the constraint (See the SQL Help files for how to use ALTER TABLE) Does this help?


        Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

        J Offline
        J Offline
        john kuruvila
        wrote on last edited by
        #3

        :)thanx....:) Jijo kuruvila software developer trivandrum

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups