Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Difference in both the Scripts

$
0
0

Hi All,

Check these two Scripts.

Script 1

SELECT CASE WHEN City__C IN ('DELHI','MUMBAI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=100000 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=100000) THEN 'Passed' WHEN City__C IN ('BANGALORE','CHENNAI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=80000 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=80000) THEN 'Passed' WHEN City__C NOT IN ('BANGALORE','CHENNAI','MUMBAI','DELHI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=40000 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=40000) THEN 'Passed' ELSE 'Failed' END Status, month1_sal__c,month2_sal__c,City__C,Branch_Name__C,* FROM SFDC_HTS..Salaried__C WHERE CreatedDate>='2013-10-01' AND CreatedDate<='2013-10-31' AND (month1_sal__c IS NOT NULL OR month2_sal__c IS NOT NULL)

Script 2

 SELECT CASE WHEN City__C IN ('DELHI','MUMBAI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=100000.00 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=100000.00) THEN 'Passed'
	     WHEN City__C IN ('BANGALORE','CHENNAI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=80000.00 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=80000.00) THEN 'Passed'
	     WHEN City__C NOT IN ('BANGALORE','CHENNAI','MUMBAI','DELHI') AND (REPLACE(REPLACE(month1_sal__c,' ',''),',','')>=40000.00 OR REPLACE(REPLACE(month2_sal__c,' ',''),',','')>=40000.00) THEN 'Passed'
	     ELSE 'Failed'
	END Status,
	month1_sal__c,month2_sal__c,City__C,Branch_Name__C,*
 FROM SFDC_HTS..Salaried__C
 WHERE   CreatedDate>='2013-10-01' AND CreatedDate<='2013-10-31'
	 AND (month1_sal__c IS NOT NULL OR month2_sal__c IS NOT NULL)

In Script 1 the values in month1_sal__c and month2_sal__c is checked with integers while in script 2 it is checked with real numbers.

The error I am getting is mentioned below.

Msg 8115, Level 16, State 8, Line 1

Arithmetic overflow error converting nvarchar to data type numeric.

But the bizarre thing is that in first script I am getting only 6 rows and then the error message and in the second script I am getting 40 rows and then the message error.

In and all there are 8446 rows which qualifies for the clause.

Please revert back.


Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>