January 25, 2007 at 1:08 pm
i would like to use OR, but don't know how to set it up.
heres what i got so far.
declare @whatever int
select @whatever = [myvalue] from
if @whatever = 'myvalue'
begin sp_this
end
else
begin sp_that
end
what if i want to use OR ?
if @whatever = 'myvalue' OR 'myvalue 2'
begin sp_this
end
else
being sp_that
end
is some thing like this possible?
thanks in advance.
_________________________
January 25, 2007 at 1:24 pm
if (@whatever = 'myvalue') OR (@whatever = 'myvalue 2')
MohammedU
Microsoft SQL Server MVP
January 25, 2007 at 1:28 pm
wow that was simple.
thanks!!
_________________________
January 25, 2007 at 1:42 pm
OR
if @Whatever in ('value1', 'value2')
This is more easily expanded.
January 25, 2007 at 1:52 pm
what? with the paren's and all that?
i noticed you have the (in) instead of (=).
does that work?
_________________________
January 25, 2007 at 2:23 pm
See for yourself :
DECLARE @X AS VARCHAR(10)
SET @X = 'Test'
IF @X IN ('t', 't2', 'Test')
BEGIN
SELECT 'Hello world'
END
January 25, 2007 at 3:38 pm
cool! you rock bro!
_________________________
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply