Results 1 to 10 of 10

Thread: Can't Delete a row in SQL Server???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    I can not delete a record in a SQL server table. I did an insert into the table using VB. I inserted this record 4 times into the Table. I can delete other records in this table but not the ones I inserted in. The error I get is as follows:

    Key Column information is insufficient or incorrect. To many rows were affected by update.

    I have tried running the SQL Query analizer and used the following code

    Delete From tTable
    Where AcctNum = "The Account Number"

    It returns and says successful but the records are still there????


  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Do you have a primary key on that table?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    No I do not have a primary key.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You don't have to use From clause.
    Try something like this:

    Delete tTable Where AcctNum = 1

    or whatever number you have there.

  5. #5
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    1) try :

    select * from tTable insert into ##tempTable Where AcctNum not = "The Account Number"

    2) if that works, then:

    delete from tTable

    3) Followed by:

    insert into tTable select * from ##tempTable.

    4) If all the above works, get rid of the temp table

    drop ##tempTable

    You will need to be logged on as sa. Make sure every step works to your liking, before proceding to the next step.




  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    I tried both scenerios and it still did not work?????

  7. #7
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Have your DBA run DBCC on your server, it sounds like there are problems with it.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    Thanks. I will see what he can do.

  9. #9
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Add an autonumber primary key to your table. Then delete where primary key = value

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    Thanks Clunietp. I added an Identity number and then I made it the primary key. I then was able to delete them!!!!!!!!!!!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width