Solved

Checking part of a Column for numeric in SYBASE SQL

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

15 Experts available now in Live!

Get 1:1 Help Now