July 22, 2008 at 4:05 am
Dear,
If a table with a VARCHAR or NVARCHAR column, its values can be either characters or numbers, now, I want to write a SELECT statement which will only extract those records have '123', '234', ........... only.
How can I write it ?
July 22, 2008 at 4:08 am
Do you mean something like this:
select * from myTable where myColumn in ('123','234','345')
Matt.
July 22, 2008 at 4:13 am
The column's data type is VARCHAR or NVARCHAR, it is assumed that user will only input numeric data, eg. 123, 3, 4, 32.
However, due to some human mistakes, some users have entered some non-numeric data, eg. 'ABC', 'cde', ....
Now, I want to SUM(the column) up but I have to exclude those 'ABC', 'cde',
How can I do that ?
July 22, 2008 at 4:17 am
Hi
Use the isnumeric function.
ex: select sum(cast(col1 as int)) from table1 where isnumeric(col1) = 1.
"Keep Trying"
July 22, 2008 at 4:18 am
Ahh, apologies. Chriag's solution would work nicely.
Matt.
July 22, 2008 at 4:22 am
Thanks every bodies.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply