473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

512 error in delete statement

I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement:



DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' ) AND Col3 IN( integer1 ) AND Col4 IN( integer2 ) AND Col5 IN( 'Some Val3' )



on TABLE1, uploads data into TABLE1 through bulk loading, calls a stored procedure that uses the data, and then deletes the data through the SAME delete statement with EXACTLY the same parameter values. The first delete statement is always successful, but the second statement intermittently gives the following error:



0,0,MS SQL Server Message :
SQL Server message 512, state 1, severity 16:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SQL Server message 3621, state 0, severity 0:
The statement has been terminated.

Note: I was initially using the equality operator instead of the IN operator in the query but that gave the same results.

The table has the schema

Table1( Col1 varchar(50) NULL, Col2 varchar(50) NULL, Col3 int NULL, Col4 int NULL, Col5 varchar(128) NULL, Col6 varchar(128) NULL, Col7 varchar(100) NULL, Col8 varchar(50) NULL, Col9 varchar(50) NULL, Col10 int NULL, Col11 int NULL, Col12 float NULL, Col13 float NULL, Col14 float NULL, Col15 float NULL )

Can somebody tell me whats going wrong here? I can easily ignore this error because my work is done after the stored proc but I fear amassing a lot of useless data in the table over time. Also http://support.microsoft.com/kb/195491 talks about a case where the delete statement is actually successful but still causes an error when using ADO. I vaguely remember hearing somewhere that delete causes a lot of problems if the table doesn't have primary keys. Is this correct?
Mar 1 '08 #1
1 3913
ck9663
2,878 Expert 2GB
I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement:



DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' ) AND Col3 IN( integer1 ) AND Col4 IN( integer2 ) AND Col5 IN( 'Some Val3' )



on TABLE1, uploads data into TABLE1 through bulk loading, calls a stored procedure that uses the data, and then deletes the data through the SAME delete statement with EXACTLY the same parameter values. The first delete statement is always successful, but the second statement intermittently gives the following error:



0,0,MS SQL Server Message :
SQL Server message 512, state 1, severity 16:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SQL Server message 3621, state 0, severity 0:
The statement has been terminated.

Note: I was initially using the equality operator instead of the IN operator in the query but that gave the same results.

The table has the schema

Table1( Col1 varchar(50) NULL, Col2 varchar(50) NULL, Col3 int NULL, Col4 int NULL, Col5 varchar(128) NULL, Col6 varchar(128) NULL, Col7 varchar(100) NULL, Col8 varchar(50) NULL, Col9 varchar(50) NULL, Col10 int NULL, Col11 int NULL, Col12 float NULL, Col13 float NULL, Col14 float NULL, Col15 float NULL )

Can somebody tell me whats going wrong here? I can easily ignore this error because my work is done after the stored proc but I fear amassing a lot of useless data in the table over time. Also http://support.microsoft.com/kb/195491 talks about a case where the delete statement is actually successful but still causes an error when using ADO. I vaguely remember hearing somewhere that delete causes a lot of problems if the table doesn't have primary keys. Is this correct?
That error happens when you're running a query that is expected to return a single result but returned two or more. It's usually when you use the result of a query and store in a variable or use it in an expression.One of the usual reason is there is a duplicate on the table. Since your DELETE query does not contain any subquery, I can only assume your error is somewhere else on your stored proc and not on your DAO.

-- CK
Mar 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
9
by: cousaert | last post by:
Newsgroups: alt.comp.lang.learn.c-c++ Date: Fri, 27 Aug 2004 12:36:11 +0200 Lines: 36 User-Agent: KNode/0.7.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
1
by: Akinyemi | last post by:
I created a Database which I named "Address". I went through the Control Panel and created a DSN to enable me connect to the Database through ODBC. I then created a Form with the same fields as...
5
by: prakashwadhwani | last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in my form were working perfectly. However, after I added a call to the "Save_Fields_In_Form_Header" Event/Proc in the...
7
by: EManning | last post by:
Using A2003. I'm receiving this error when returning from a "DoCmd.OpenReport..." statement. I have a tab control with a subform on every tab. The user selects an item from a combobox at the top...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.