all groups > sql server programming > september 2006 >
You're in the

sql server programming

group:

getting strange error


getting strange error Rudy
9/30/2006 11:33:01 AM
sql server programming:
Hi All!
I have a SP like this.
CREATE PROCEDURE [dbo].[GetNumWinners
AS
BEGIN
DECLARE @WinNum numeric(10)
DECLARE @Total numeric(20)
DECLARE @Win numeric(20)
DECLARE @UserID nvarchar
DECLARE @House numeric(20)
DECLARE @Guest numeric(20)

SET @WinNum = (SELECT COUNT(*) FROM TblUserID WHERE Pass = '1')
SET @Total = (SELECT MAX (TotalPool) FROM Pool)
SET @House = (@Total * 0.2)
SET @Guest = (@Total - @House)
SET @Win = (@Guest/ @WinNum)
SET @UserID = (SELECT USERID FROM tblUserID WHERE Pass = '1')
SET @Win =(SELECT @Win As Winner)

UPDATE Bankroll
SET Credits = Credits + CAST(@win as int)

WHERE UserID IN (SELECT USERID FROM tblUserID WHERE Pass = '1')

END
GO
Getting this error "Subquery returned more than 1 value. This is not
permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery
is used as an expression."

I know what this means, just not sure how to fix it. This statement will
always return more than one value. So how do I get around this?

Thanks!

Rudy

Re: getting strange error Rudy
9/30/2006 11:54:02 AM
That was it!!

Thanks Serinus!!

Rudy

[quoted text, click to view]
Re: getting strange error Sericinus hunter
9/30/2006 2:39:22 PM
It is probably complaining about SET @UserID = (SELECT...) line.
Get rid of it and everything should go fine.

[quoted text, click to view]
AddThis Social Bookmark Button