SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

saidev
Posting Yak Master

101 Posts

Posted - 06/28/2006 :  20:09:47  Show Profile  Reply with Quote
Guys,


I am trying to run these queries in the stored procedure but I am getting the message
Can you guys help me what I am doing wrong
Thanks


Message "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." String


This is my Stored Procedure


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),
fkprogrambuynumber = s.fkprogrambuynumber
FROM tblTempDRSRecord_Contracts t, tblTempDRSRecord s
WHERE t.FTSOrderNumber = s.FTSOrderNumber


insert into tbladvertiser
(descr,description) SELECT DISTINCT left(advertiser,10) ,advertiser
FROM 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)

USA
7020 Posts

Posted - 06/28/2006 :  20:18:11  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000