Prev: I assume Row_Number doesn’t act only onrows of the window frame
Next: US-MD-Silver Spring: SQL VMWare TV Network DBA
From: BruceL on 3 May 2010 10:09 On Apr 30, 6:06 pm, DavidC <dlch...(a)lifetimeinc.com> wrote: > I am trying to end a stored procedure and return a value of -1 to tell the > application that a check number already exists. Below is the code in my sp > where I am checking but it goes right past it and continues as though the > result is false. When I run this as a separate query it returns the -1 fine. > Can anyone see what might be wrong? Thanks. > > DECLARE @Return int; > > IF @Duplicate = 1 AND EXISTS (SELECT dbo.PayChecks.CheckNumber > FROM dbo.PayChecks INNER JOIN > dbo.PeopleLink ON dbo.PayChecks.PeopleLinkID = > dbo.PeopleLink.PeopleLinkID > WHERE (dbo.PayChecks.CheckNumber = @NewCheckNumber) > AND (dbo.PeopleLink.Branch = @Branch)) > BEGIN > SET @Return = -1 > RETURN @Return > END > > -- > David This might simply be an expression precedence problem, try parenthesis IF (@Duplicate = 1) AND EXISTS |