473,793 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subquery returned more than 1 value. This is not permitted when the subquery...

3 New Member
I have a stored procedure that calls another stored procedure on a different server. I get the error i wrote above. The first procedure is:
Expand|Select|Wrap|Line Numbers
  1. set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
  2. set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
  3. DECLARE @exec_statement varchar (100)
  4. select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
  5. exec @exec_statement
the second procedure
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDERE [dbo].[DeleteUsers] AS
  2. DELETE FROM all_accounts
  3. WHERE userid in (SELECT userid FROM dbo.temp_accounts)
im completely sure that the problem doesn't occur because of the first 2 selects (the db_name and server_address) , so it must be the second procedure, but the second procedure *should* return more then one row (for that i use 'in' instead of '=')! how is this possible?
Mar 26 '08 #1
7 1767
ck9663
2,878 Recognized Expert Specialist
I have a stored procedure that calls another stored procedure on a different server. I get the error i wrote above. The first procedure is:
Expand|Select|Wrap|Line Numbers
  1. set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
  2. set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
  3. DECLARE @exec_statement varchar (100)
  4. select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
  5. exec @exec_statement
the second procedure
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDERE [dbo].[DeleteUsers] AS
  2. DELETE FROM all_accounts
  3. WHERE userid in (SELECT userid FROM dbo.temp_accounts)
im completely sure that the problem doesn't occur because of the first 2 selects (the db_name and server_address) , so it must be the second procedure, but the second procedure *should* return more then one row (for that i use 'in' instead of '=')! how is this possible?

Try isolation:

Run these first and see if there's an error:

Expand|Select|Wrap|Line Numbers
  1. set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
  2. set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
  3. select @dbname, @server_address
  4.  
Then run this
Expand|Select|Wrap|Line Numbers
  1. DECLARE @exec_statement varchar (100)
  2. select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
  3. exec @exec_statement
However, instead of those variables, try and pass the hardcoded value of those variables. You can get it from the select statement you first ran.

It will tell you where the error is.

-- CK
Mar 26 '08 #2
blabla2006
3 New Member
Try isolation:

Run these first and see if there's an error:

Expand|Select|Wrap|Line Numbers
  1. set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
  2. set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
  3. select @dbname, @server_address
  4.  
Then run this
Expand|Select|Wrap|Line Numbers
  1. DECLARE @exec_statement varchar (100)
  2. select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
  3. exec @exec_statement
However, instead of those variables, try and pass the hardcoded value of those variables. You can get it from the select statement you first ran.

It will tell you where the error is.

-- CK
the problem is not in these variables. even if i use select max(db_name) i get the problem. i realy think its the second procedure.
Mar 26 '08 #3
deepuv04
227 Recognized Expert New Member
the problem is not in these variables. even if i use select max(db_name) i get the problem. i realy think its the second procedure.
hi,
I think the following statement is returning more than one vlaue

Expand|Select|Wrap|Line Numbers
  1.  
  2. select db_name from all_servers where server_no = @server_no
  3.  
  4. or
  5.  
  6. select server_address from all_servers where server_no = @server_no
  7.  
  8.  
execute these two statements alone and see how many rows it is returning

thanks
Mar 26 '08 #4
ck9663
2,878 Recognized Expert Specialist
"Egsakli" what am trying to suggest ;)

-- CK
Mar 26 '08 #5
blabla2006
3 New Member
I said its not these two selects. I tried to execute the program wih hard-coded values ot use the 'max' aggregate but i still get this error.
Mar 26 '08 #6
ck9663
2,878 Recognized Expert Specialist
Then execute this with hard coded values for @server_address and @dbname
Expand|Select|Wrap|Line Numbers
  1.       DECLARE @exec_statement varchar (100)
  2.       select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
  3.       exec @exec_statement
-- CK
Mar 26 '08 #7
deepuv04
227 Recognized Expert New Member
hi,
I think the following statement is returning more than one vlaue

Expand|Select|Wrap|Line Numbers
  1.  
  2. select db_name from all_servers where server_no = @server_no
  3.  
  4. or
  5.  
  6. select server_address from all_servers where server_no = @server_no
  7.  
  8.  
execute these two statements alone and see how many rows it is returning

thanks
Hi,
Did you tried the above code...?

okey change the statements in your procedure to: (just replace SET to SELECT and try )

Expand|Select|Wrap|Line Numbers
  1.  
  2.       select @DB_NAME = (select db_name from all_servers where server_no = @server_no)
  3.  
  4.       select @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
  5.  
  6.  
and try ...
Mar 27 '08 #8

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

Similar topics

0
1590
by: leegold2 | last post by:
I tried what's below, seemed OK, so I replaced an "IN" for the "=" in the subquery below because of the subquery's error message. I thought w/"IN" I'd get three (3) records returned as expected. But when I tried "IN" I got my entire DB returned - I don't show that below - it kept scrolling so I aborted it. What did I do wrong? Seems like the inner just returns three recs. and should match-up w/the outer for three recs. too. I'm using 4.1....
2
2061
by: Nachi | last post by:
Hi, Urgent Help appreciated.... I am getting resultset with first condition and when try to get the resutlset from second condition i am getting the above error in SQL200. I know that i am getting more then one value in the second condition but even i am getting more then one value in my first statement
5
6595
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the following SQL statement. INSERT INTO OrderItems (ClientID, ProductID, OrderHeaderID, Quantity, Dispatched, BackOrdered) SELECT ClientID, ProductID, 1371 AS OrderHeaderID, Quantity, Dispatched, BackOrdered FROM Basket WHERE RequisitionID = 1369 The...
2
1943
by: reap76 | last post by:
I am running the following query: if (select IntExternalAccountID from ExternalAccount) = (select IntExternalAccountID from InternalAccount) select * from InternalAccount where AccountPurpose=2 and getting the following error Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. What I am attempting is if the values in ColumnA from...
3
2921
by: Shals | last post by:
Hi, I'm using Form and a subform control within that form. Main form is getting data from one table(Buildings) and subform is getting data from another table(BldgDataByFloor). but both the form and subform are linked through a child field which is common in both the tables(BuildingNumber). Now, whenever I close the form I receive an error "Subquery returned more than 1 value. This is not permitted when the
0
2074
by: kiran2nirvan | last post by:
hi please help in solving this i am recieving this error"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression." for the code CREATE procedure . (@frmMasterID int,
0
1304
by: abednegoo | last post by:
Hi All, I tried to find the solution for my problem, but i couldn't find it. If my problem is already solved somewhere, please provide me the link... I'm not a developer myself, but the application manager who needs to solve the issue :) I have got a problem with out software. It throws an error (Subquery returned more than 1 value, blablabla) at me and I cannot see why. I have this data which is stored in an XSD file. The query is the...
1
2245
by: Aleck | last post by:
Hie. I have a trigger that monitors changes to my table fields but I get an error saying subquery returned more than one value.Below is the code for my trigger, hope you will figure out whats happening.. CREATE TRIGGER trgmyTableAuditFields ON myTable WITH ENCRYPTION FOR INSERT, UPDATE, DELETE AS BEGIN
2
1532
by: neilgilbert1234 | last post by:
Hi Everyone, Im sure this is an easyone, im a newbie to anything half complex in sql so any help would be greatly appreaciated. I have one table that has two values, i need to multiply those values and stick the result back into the table. I have used the script below but getting an error: "Subquery returned more than 1 value. This is not permitted when the subquery follows" Script used: update dbo.PCProjectEntry set...
3
11396
by: jideesh | last post by:
---------------trigger code create trigger DeletepurchaseItems on table_purchaseitems for delete,update as begin select * from deleted update table_STOCK set ostock=(ostock-(select sqty from deleted)) where itemcode=(select itemcode from deleted)and coid=(select compid from deleted) and fycode=(select financialyear from deleted) end
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.