Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Checking if a field value is numerical

Author  Topic 

NiceSituation
Starting Member

22 Posts

Posted - 2007-10-31 : 14:01:47
I have a table in my database in which a certain field (let's call it "card number") is defined as varchar. Sometimes this field will be a numerical value (contains only numbers), and sometimes it will include non-numerical characters (that's why we did not define it as integer, though the value may include numerical characters together with non-numerical characters). What I would like to do is create a view in which I get all rows whose card number is a numerical value, and another view in which I get all rows whose card number is non-numerical. However, I cannot think of a way to do this. Any suggestions?

May today be good, and tomorrow better

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-31 : 14:09:41
http://weblogs.sqlteam.com/mladenp/archive/2007/10/18/SQL-Server-Filtering-Numeric-data-from-a-character-based-column.aspx

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

NiceSituation
Starting Member

22 Posts

Posted - 2007-10-31 : 15:11:58
Thanks, that's just what I needed.

May today be good, and tomorrow better
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-01 : 02:44:40
Other method

Select.......
Where ISNUMERIC(col+'d0')=1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -