Solved

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

Posted on 2012-12-24
3
348 Views
Last Modified: 2012-12-25
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 (
0
Comment
Question by:afifosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:igordevelop
ID: 38719959
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
0
 
LVL 1

Author Comment

by:afifosh
ID: 38719964
i want to match the two restriction in the same time
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 38719974
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

0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question