With that out of the way, my original problem did not disappear.
TEST 1:
SELECT CONVERT(INT, nsFramework.dbo.fncFormulaCalculation(5, 1, tYear, tMonth, 0))
FROM dbo.tblTallyTable_Periods
WHERE tYear = 2014
-----------
26746
23014
27048
26326
27356
25219
27667
27823
25650
28139
27386
26956
TEST 2: (fail)
CREATE TABLE #Temp (
Result INT)
INSERT INTO #Temp
SELECT CONVERT(INT, nsFramework.dbo.fncFormulaCalculation(5, 1, tYear, tMonth, 0))
FROM dbo.tblTallyTable_Periods
WHERE tYear = 2014
SELECT * FROM #Temp
DROP TABLE #Temp
(12 row(s) affected)
Result
-----------
0
0
0
0
0
0
0
0
0
0
0
0
(12 row(s) affected)
Now why would the exact same statement fails only because I am trying to insert the result into a temp table? I know it is the clr function that is returning the zeroes, because I set the result to 0 when an error is occured. So something changes when I try to write back to SQL and the clr function knows about the change. The question is what must I change in the clr for it to work the same with test 1 and test 2?
5ilverFox
Consulting DBA / Developer
South Africa