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();
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)
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/