1

HERE IS THE FUNCTION:

ALTER FUNCTION dbo.FN_GET_QUARTER
 -- the parameters for the function here
(
  @FN_Qtr_date  datetime 
)

RETURNS INT
AS
BEGIN

    RETURN datepart(qq,@FN_Qtr_date)
END 

HERE IS THE SQL REPORT:

IF(SELECT(OBJECT_ID('TEMPDB..#T1'))) IS NOT NULL DROP TABLE #T1


SELECT      L_NUMBER, LAST_MAINTENANCE_DATE,
            dbo.FN_FICO_BANDS (LAST_MAINTENANCE_DATE) AS  FN_Qtr_date
INTO  #T1
FROM  OPENQUERY(SrvLink, '

SELECT      LOAN_NUMBER,LAST_MAINTENANCE_DATE
FROM  BDE.loan_V
FETCH FIRST 1000 ROWS ONLY WITH UR ')
GO


SELECT      COUNT(*), FN_Qtr_date

FROM  #T1
GROUP BY FN_Qtr_date
ORDER BY FN_Qtr_date

Results:

 L count               FN_Qtr_Date
  150                   Invalid
  355                   Invalid

I am not sure what I am doing wrong..

1
  • 1
    You define FN_GET_QUARTER and call FN_FICO_BANDS :-? Commented Jul 2, 2010 at 19:34

2 Answers 2

1

The first thing that jumps out at me is that you're calling dbo.FN_FICO_BANDS instead of dbo.FN_GET_QUARTER

Sign up to request clarification or add additional context in comments.

Comments

0

dbo.FN_FICO_BANDS (LAST_MAINTENANCE_DATE) AS FN_Qtr_date

If you're going to use the function on LAST_MAINTENANCE_DATE, you need to use: dbo.FN_Qtr_Date(LAST_MAINTENANCE_DATE) AS YourQuarter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.