Author |
Topic |
ann
Posting Yak Master
220 Posts |
Posted - 2009-04-20 : 18:09:49
|
I get the following error when I try to run my sp:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expressionthis is my sp:-- Add the parameters for the stored procedure here @rptID intASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; declare @trgID int set @trgID = (select targetID from tblsections where reportid = @rptID) select * from tblUserTargets ut join tblusers u on u.userid = ut.userid where ut.targetid in (select targetID from tblUserTargets) what do I need to change to make this work? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ann
Posting Yak Master
220 Posts |
Posted - 2009-04-20 : 18:46:51
|
yes .. I knew that ... but when I ran it in query analyzer, it returned all the correct values?What I want is all the targetID's in the tblsections to get the results in the second queryBy the way, I am using 2000 to test these queries since that is where the data resides - it will be moved to 2005, hopefully in a couple of months |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ann
Posting Yak Master
220 Posts |
Posted - 2009-04-20 : 18:56:21
|
Sorry, sometimes it's hard to put in words what you are thinking.Anyway, maybe this is more clear - I am passing in the param of reportID = 8 in this example:tblsectionstargetID reportID1 72 83 8tblusertargetsuserID targetID1 22 13 3tblUsersuserID firstname lastname1 mickey mouse2 minnie mouse3 john doeresults1 mickey mouse3 john doe |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ann
Posting Yak Master
220 Posts |
Posted - 2009-04-20 : 19:02:53
|
yes that works.. thankssigh... don't know why I made it so much more complicated |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|