Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update problem when subquery returns multiple results 1

Status
Not open for further replies.

cwbrumett

Programmer
Dec 9, 2005
12
US
I'm having a weird problem, I'm trying to update a table where the pkey is InvItemNum and InvCompanyCode (on both tables) ... the problem is when I try to execute the below statement it returns the error

Server: Msg 512, Level 16, State 1, Procedure trg_UpdateItem, Line 4
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

but if I do a
Code:
SELECT InvItemNum, InvCompanyCode  FROM SISMaster..SIS_Inventory_Master
it returns 1503 records
and if I do
Code:
SELECT DISTINCT InvItemNum, InvCompanyCode  FROM SISMaster..SIS_Inventory_Master
it returns 1503 records ... I don't get how it can return multiple results from the subquery because there is NO duplicated data (as well as, it's the pkey I'm joining on)

here's the update statement that is producing the error,
Code:
update SISMaster..SIS_Inventory_Master 
set 
	SISMaster..SIS_Inventory_Master.InvItemDesc = M.InvItemDesc,
	SISMaster..SIS_Inventory_Master.InvProductGrp = M.InvProductGrp,
	SISMaster..SIS_Inventory_Master.InvWeight = M.InvWeight,
	SISMaster..SIS_Inventory_Master.InvAverageCost = M.InvAverageCost,
	SISMaster..SIS_Inventory_Master.InvCasesPerPallet = M.InvCasesPerPallet,
	SISMaster..SIS_Inventory_Master.InvStandardCost = M.InvStandardCost

FROM SISTrx..SIS_Inventory_Master M
WHERE 
	M.InvItemNum=SISMaster..SIS_Inventory_Master.InvItemNum
	AND M.InvCompanyCode=SISMaster..SIS_Inventory_Master.InvCompanyCode

thanks for any help, I'm so lost right now on this one.
 
How many records do you get back with the joined SELECT statement?

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Eschewing obfuscation diurnally.
 
There are no subqueries in code above.

Maybe there are some triggers below the surface?

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Yup:

> Server: Msg 512, Level 16, State 1, Procedure [!]trg_[/!]UpdateItem, Line 4

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
AHHHHH! forgot to check for triggers! that was it, my brain has been fried all morning on why that wouldn't work.

THANK YOU!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top