Click to See Complete Forum and Search --> : Can't Delete a row in SQL Server???
Steve Thomas
Apr 12th, 2000, 05:01 AM
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????
Clunietp
Apr 12th, 2000, 10:20 PM
Do you have a primary key on that table?
Steve Thomas
Apr 12th, 2000, 10:43 PM
No I do not have a primary key.
Serge
Apr 12th, 2000, 11:26 PM
You don't have to use From clause.
Try something like this:
Delete tTable Where AcctNum = 1
or whatever number you have there.
JHausmann
Apr 12th, 2000, 11:27 PM
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.
Steve Thomas
Apr 13th, 2000, 12:05 AM
I tried both scenerios and it still did not work?????
JHausmann
Apr 13th, 2000, 12:34 AM
Have your DBA run DBCC on your server, it sounds like there are problems with it.
Steve Thomas
Apr 13th, 2000, 12:36 AM
Thanks. I will see what he can do.
Clunietp
Apr 13th, 2000, 09:39 PM
Add an autonumber primary key to your table. Then delete where primary key = value
Steve Thomas
Apr 16th, 2000, 09:22 PM
Thanks Clunietp. I added an Identity number and then I made it the primary key. I then was able to delete them!!!!!!!!!!!!!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.