Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql server2000 a string that contains digits only 2

Status
Not open for further replies.

duchovnick

Programmer
Jan 4, 2007
115
IL
Hi,
In my table there's a string type column.
I want it to contain digits only.
I want to see all lines with that string having any other character
but a digit.
I search a code that will do something like
Code:
SELECT
myStringCol
WHERE
All characters>='0' AND
all_characters<='9'
"All charcters" is my "wishfull thinking" And i'd like to ask someone
who is more realistic then i am to tell me what "All characrers"
should be replaced with.
Thanks a lot !
 
Have a look at the PATINDEX function, that should do what you need.


Hope this helps.

[vampire][bat]
 
Try this:
Code:
 ... where COL like '%[^0-9]%'
Returns with all rows having not numeric character in COL.
 
Take a look at this Frequently Asked Question. faq183-6423

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Hi Otto
I ran your code changing it into "not like rather than like and it worked OK!
thanks A LOT !
HI Earhandfire
Either i didnt understand it or it didnt match excactly my need, I couldnt use the PATINDEX keyword.
And thank you GMMastros !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top