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


Avoid ISNumeric and dealing with Nullable Columns


Avoid ISNumeric and dealing with Nullable Columns

Author
Message
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
I have what is not ideal data that I have to work with.

For example I have a column CD_Limit that contains numeric values, characters such as $, %, etc.

I create a numeric column to store the data so that it is useful for reports, etc.

I used SQL Enlight and I got the warning 'Avoid using ISNUMERIC function as it accepts floating point and monetary number.'

I was also advised to use ISNULL on the CD_Limit column but with the values in the column which I referred to above, I'm not sure what to use as a default or if I can even use that function.

Any suggestions on how I can improve this query would be appreciated.



DECLARE @Date Date;
DECLARE @CD_Limit_ISNull CHAR (1);
SET @CD_Limit_ISNull = ' ';

SET @Date = GetDate();

UPDATE MY_DIMENSION
SET CD_LIMIT_NUMERIC = CASE
WHEN CD_LIMIT = 'NONE' THEN 0
--ELSE ISNULL(CD_LIMIT, 0)
WHEN ISNUMERIC(MY_DIMENSION.CD_LIMIT) = 0 THEN 0
ELSE ISNULL(CD_LIMIT, @CD_Limit_ISNull)
END
WHERE CD_STG_SOURCE_SYSTEM = 'RDB_DWH'
AND CD_DW_INSERT_DATE > DATEADD(DAY, -7,@Date);



For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
I get the following warning when using SQL Enlight:


Avoid using ISNUMERIC function as it accepts floating point and monetary number.



For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Evil Kraig F
Evil Kraig F
SSCrazy Eights
SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)

Group: General Forum Members
Points: 8663 Visits: 7660
I'm not overly familiar with enlight, but your approach seems reasonable. The big deal with that is the scientific float items (1.03E-12) which may/may not fit into the target. You may want to wrap for that with an upper/lower bound for the values.


- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Welsh Corgi
Welsh Corgi
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10262 Visits: 4894
Thanks Kraig.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
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