Solved

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

Posted on 2012-12-24
3
344 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
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 68

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now