Solved

Checking part of a Column for numeric in SYBASE SQL

Posted on 2009-07-09
5
596 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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 …

770 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