Solved

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

Posted on 2012-12-24
3
345 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 69

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

803 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