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: - set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
-
set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
-
DECLARE @exec_statement varchar (100)
-
select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
-
exec @exec_statement
the second procedure - ALTER PROCEDERE [dbo].[DeleteUsers] AS
-
DELETE FROM all_accounts
-
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?
7 1749
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: - set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
-
set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
-
DECLARE @exec_statement varchar (100)
-
select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
-
exec @exec_statement
the second procedure - ALTER PROCEDERE [dbo].[DeleteUsers] AS
-
DELETE FROM all_accounts
-
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: - set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
-
set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
-
select @dbname, @server_address
-
Then run this - DECLARE @exec_statement varchar (100)
-
select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
-
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
Try isolation:
Run these first and see if there's an error: - set @DB_NAME = (select db_name from all_servers where server_no = @server_no)
-
set @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
-
select @dbname, @server_address
-
Then run this - DECLARE @exec_statement varchar (100)
-
select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
-
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.
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 -
-
select db_name from all_servers where server_no = @server_no
-
-
or
-
-
select server_address from all_servers where server_no = @server_no
-
-
execute these two statements alone and see how many rows it is returning
thanks
"Egsakli" what am trying to suggest ;)
-- CK
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.
Then execute this with hard coded values for @server_address and @dbname -
DECLARE @exec_statement varchar (100)
-
select @exec_statement = '[' + @SERVER_ADDRESS + '].' + @DB_NAME + 'dbo.DeleteUsers'
-
exec @exec_statement
-- CK
hi,
I think the following statement is returning more than one vlaue -
-
select db_name from all_servers where server_no = @server_no
-
-
or
-
-
select server_address from all_servers where server_no = @server_no
-
-
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 ) -
-
select @DB_NAME = (select db_name from all_servers where server_no = @server_no)
-
-
select @SERVER_ADDRESS = (select server_address from all_servers where server_no = @server_no)
-
-
and try ...
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |