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 |
blackX
Posting Yak Master
102 Posts |
Posted - 2008-01-08 : 10:46:02
|
I created a stored procedure this morning and it compiled fine. I then started working on a new vb project. Now when I run the stored proc it gives me this SQL error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.Here is the procedure:USE [Premier]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate procedure [dbo].[SalesTeamInfoInsert](@begin smalldatetime,@end smalldatetime)asINSERT INTO salesteaminfo( teamid,teamcommissionpercent, teamstartdate, teamenddate) SELECT (select distinct salesrep from member where prestndate between @begin and @end), 11.38, @begin, @endTHANKS for any help you can give! |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-08 : 10:51:40
|
the error is herequote: (select distinct salesrep from member where prestndate between @begin and @end)
this statement, a sub-query is returning more than one row of result.try thisSELECT distinct salesrep , 11.38 , @begin , @endfrom member where prestndate between @begin and @end KH[spoiler]Time is always against us[/spoiler] |
 |
|
blackX
Posting Yak Master
102 Posts |
Posted - 2008-01-08 : 11:38:09
|
quote: Originally posted by khtan the error is herequote: (select distinct salesrep from member where prestndate between @begin and @end)
this statement, a sub-query is returning more than one row of result.try thisSELECT distinct salesrep , 11.38 , @begin , @endfrom member where prestndate between @begin and @end KH[spoiler]Time is always against us[/spoiler]
I want to select more than one rep, I want to insert all distinct reps for the week range |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-08 : 11:50:45
|
Try this:-USE [Premier]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate procedure [dbo].[SalesTeamInfoInsert](@begin smalldatetime,@end smalldatetime)asINSERT INTO salesteaminfo( teamid,teamcommissionpercent, teamstartdate, teamenddate)SELECT distinct salesrep , 11.38, @begin, @endfrom member where prestndate between @begin and @end |
 |
|
blackX
Posting Yak Master
102 Posts |
Posted - 2008-01-08 : 12:55:30
|
Thanks it work just as described |
 |
|
|
|
|
|
|