SQL 23505

Posted on 2012-09-02
Last Modified: 2013-08-07
I have an existing table, and the employee_id columns contain 0. So I decided to add a unique constraint to employee_id, but I got error SQL state: 23505. To solve this problem,  what should I do?
Question by:JavaTears
    LVL 37

    Accepted Solution

    How nice of you to select 3 database types, please let us know which one this is about so we can help you better :)

    But to help fix your issue, is there a difference between:

    select count (employee_id) from your_table;


    select distinct (employee_id) from your_table;

    In case there is a difference then the constraint cannot be applied because you do not have unique values in your_table's employee_id field.
    LVL 31

    Assisted Solution

    >>I have an existing table, and the employee_id columns contain 0.<<
    The error is due to the fact that your employee_id column does not contain unique values (e.g. there are multiple 0's in the column), which are necessary to create a unique constraint. You would need to update the column so that the values are unique before adding the constraint. Which dbms are you actually using since that would determine how the update would need to be applied?
    LVL 37

    Expert Comment

    by:Gerwin Jansen
    @awking00 - I'm also suggesting that employee_id is not having unique values :D
    LVL 22

    Expert Comment

    by:Steve Wales
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
    Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now