tsql check field if is a number from 1 to 40 ??

AFIF JABADO
AFIF JABADO used Ask the Experts™
on
i have field @message selected from
select @message = message from inserted
select @reqport = reqport from inserted
i want to check if this @message is between 1 to 40
maybe the message contain other word i want to check if it's numeric and if @message is a number from 1 to 40

and i want to add for the first one to check if @reqport is 1234 or 4567 or 7890 and the message between 1 to 40

how i can write this using if (
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

IF @message > 1 and @message < 40
BEGIN
  //SOME SQL
END
ELSE
 //SOME SQL

same goes for @reqport

IF @reqport = 1234 OR @reqport = 4567 OR @reqport = 7890
BEGIN
 //SOME SQL
END
ELSE
 //SOME SQL

Author

Commented:
i want to match the two restriction in the same time
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
Maybe
IF @message between 1 and 40 and @reqport in (1234, 4567, 7890)
BEGIN
  -- sql if true
END
ELSE
BEGIN
  -- sql if false
END

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial