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
Solved

Checking part of a Column for numeric in SYBASE SQL

Posted on 2009-07-09
5
600 Views
Last Modified: 2012-05-07
iF A COLUMN IS CHAR (8) NAMED ANYFIELD1.  AND THE TABLE NAME IS "ANYTABLE1'
How can I select all rows from table ANYTABLE1where ANYFIELD1  HAS THE LAST 4 CHARACTERS NUMERIC.

   
0
Comment
Question by:garyinmiami2003
  • 3
5 Comments
 
LVL 8

Expert Comment

by:koppcha
ID: 24817040
IN 15.0 I think you can use

isnumeric(substring(anyfield1,5,4))=1
0
 
LVL 8

Accepted Solution

by:
koppcha earned 275 total points
ID: 24817351

check if this works

SELECT *
FROM    ANYTABLE1
WHERE  SUBSTRING(ANYFIELD1,5,4) NOT LIKE '%[^0-9]%'
0
 
LVL 6

Assisted Solution

by:IncisiveOne
IncisiveOne earned 225 total points
ID: 24817525
If you want characters 5 to 8 that ARE numeric, that should be

SELECT *
FROM    ANYTABLE1
WHERE  SUBSTRING(ANYFIELD1,5,4)  LIKE '[0-9][0-9][0-9][0-9]'

Cheers
0
 
LVL 8

Expert Comment

by:koppcha
ID: 24817763
I think they both are same
one is saying not to select if it has atleast one non interger data and other one i saying to select data if all 4 charaters are digits.
0
 

Author Closing Comment

by:garyinmiami2003
ID: 31601716
I awarded the most points for the one I used.  I decided that the positive logic as opposed to negative was better for what I am doing but either would be acceptable.  Thank you very much for the assistance  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This article describes how to reset your Windows 10 password when you've forgotten it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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