SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Extracting a Numeric Reference from a VARCHAR field


Extracting a Numeric Reference from a VARCHAR field

Author
Message
brewmanz
brewmanz
Mr or Mrs. 500
Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)Mr or Mrs. 500 (561 reputation)

Group: General Forum Members
Points: 561 Visits: 406
I'm glad that this QOTD caused some deep thinking. It was prompted by a real-life problem, although it wasn't as constrained as I made it. The original input field was VARCHAR255) and failing on convert to INT when it had about 30 digits. The code was so bad that most would have seen the potential flaws. On playing with a way to fix it, I realised how (just about) useless ISNUMERIC is.
What's the proper solution? I haven't actually worked that out! LOL

I like writing QOTD (okay, I've only done 2 so far!) where you can't easily cheat by just paste-and-go (like, umm, the author has been know to do).
I'm working on another one using date formats. Sadly, I have to work for a living so progress isn't as quick as I would like. Still, watch this space!

Regards

Brewmanz
Anipaul
Anipaul
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7423 Visits: 1407
Nice one...Smile



Tom Thomson
Tom Thomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14586 Visits: 12238
brewmanz (11/24/2008)
I'm glad that this QOTD caused some deep thinking. It was prompted by a real-life problem, although it wasn't as constrained as I made it. The original input field was VARCHAR255) and failing on convert to INT when it had about 30 digits. The code was so bad that most would have seen the potential flaws. On playing with a way to fix it, I realised how (just about) useless ISNUMERIC is.
What's the proper solution? I haven't actually worked that out! LOL

I like writing QOTD (okay, I've only done 2 so far!) where you can't easily cheat by just paste-and-go (like, umm, the author has been know to do).
I'm working on another one using date formats. Sadly, I have to work for a living so progress isn't as quick as I would like. Still, watch this space!

Regards

Brewmanz


Definitely one of the better QOTD. The type of teh case statement was obviously wrong but easily fixable by changing the line marked (A), so it would be easy to go for the wrong answer without thinking about the real meaning of isNumeric. And thd explanation of teh anser is clear and correct. I liked this one very much.

Tom

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search