Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2011
    Posts
    47

    Unanswered: how to avoid null values

    i m using this for not allowing my users to put null values inside the textbox
    Code:
    create table info6(ename varchar(22) NOT NULL)
    but after checking whether this works fine or not then by executing this statement i came to know that it is allowing null values

    Code:
    insert into info6 values ('')
    please tel me how to avoid null values i have googled also then i had come up to this but this is also not working hope any one here could help me out

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Try: insert into info6 values(null)

    What do you conclude from the result.

    You should conclude that ''<>null.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    As PracticalProgram pointed out, the NOT NULL clause prevents NULL values. What you want is to avoid empty strings using something like:
    Code:
    ALTER TABLE info6
       ADD CONSTRAINT XCK01_info6
          CHECK ('' <> ename)
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Oracle (and perhaps some of the other RDBMSs out there) consider empty string and NULL to be the same thing. SQL Server does not.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by MCrowley View Post
    (and perhaps some of the other RDBMSs out there)
    well, it wouldn't surprise me, but i've never heard of any that do
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Sep 2011
    Posts
    75
    Hello,

    You need to handle this from the front end as this value is an empty string not a null value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •