May 10, 2022 at 12:58 pm
In this case i am expecting the else statement to execute. please correct
dECLARE @BusinessEntityId INT
SET @BusinessEntityId=1003
IF @BusinessEntityId<=(SELECT MAX(BusinessEntityId) AS BusinessEntityId FROM Person.Person)
BEGIN
SELECT * FROM Person.Person
WHERE BusinessEntityID<=@BusinessEntityId
END
ELSE
IF @BusinessEntityId>=1000 AND @BusinessEntityId<2000
SELECT * FROM Person.Person
WHERE BusinessEntityID>=@BusinessEntityId AND BusinessEntityID<=@BusinessEntityId
May 10, 2022 at 3:37 pm
Your final WHERE clause makes no sense:
WHERE BusinessEntityID >= @BusinessEntityId AND BusinessEntityID <= @BusinessEntityId;
This is equivalent to
WHERE BusinessEntityID = @BusinessEntityId
Is that what you meant?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
May 10, 2022 at 3:41 pm
Well what value does this return?
(SELECT MAX(BusinessEntityId) AS BusinessEntityId FROM Person.Person)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply