Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
saidev
Posting Yak Master
101 Posts |
Posted - 2006-06-28 : 20:09:47
|
Guys,I am trying to run these queries in the stored procedure but I am getting the messageCan you guys help me what I am doing wrongThanksMessage "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.Cannot insert duplicate key row in object 'tblAdvertiser' with unique index 'ndxDescr'.The statement has been terminated.The statement has been terminated." StringThis is my Stored ProcedureUPDATE tblTempDRSRecord_Contracts SET fkContractType = 'OUNWIRED', fkClient = s.fkRepresentedEntity, fkTrafficSystem = s.TrafficSystem, date = s.OrderDate, product = s.ProductName, Advertiser = s.Advertiser, fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser), fkprogrambuynumber = s.fkprogrambuynumber FROM tblTempDRSRecord_Contracts t, tblTempDRSRecord s WHERE t.FTSOrderNumber = s.FTSOrderNumberinsert into tbladvertiser (descr,description) SELECT DISTINCT left(advertiser,10) ,advertiserFROM tblTempDRSRecord_contracts where tblTempDRSRecord_contracts.fkadvertiser is null UPDATE tblTempDRSRecord_Contracts SET fkContractType = 'OUNWIRED', fkClient = s.fkRepresentedEntity, fkTrafficSystem = s.TrafficSystem, date = s.OrderDate, product = s.ProductName, Advertiser = s.Advertiser, fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser) FROM tblTempDRSRecord_Contracts t, tblTempDRSRecord s WHERE t.FTSOrderNumber = s.FTSOrderNumber AND fkAdvertiser is null |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-06-28 : 20:18:11
|
This subquery is returning more than one value, and that is not allowed when the subquery result is assigned as a column value.fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser), The other message means that you are trying to insert a row that would cause a duplicate.CODO ERGO SUM |
|
|
|
|
|
|
|