views:

30

answers:

1
ALTER PROCEDURE [Lending].[uspHMDALarIncomeGet] (@ApplicationId int)
AS
BEGIN
    SET NOCOUNT ON
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

    -- Total Income Data
    DECLARE @ApplicantId int = (SELECT AT.ApplicantId FROM Lending.Applicant AT WHERE AT.ApplicationId = @ApplicationId)

    SELECT
    I.Amount
    FROM Lending.Income I WHERE I.ApplicantId = @ApplicantId

END

Do you guys know how this proc can be written to succeed in 05?

-Scott

+5  A: 

SQL2005 does not have the syntax to declare and assign a variable in the same statement. You would need to change

  DECLARE @ApplicantId int = (SELECT ...

To

  DECLARE @ApplicantId int

  SELECT  @ApplicantId = AT.ApplicantId 
  FROM Lending.Applicant AT 
  WHERE AT.ApplicationId =   @ApplicationId

Edit:

It's just occurred to me that I might have changed the semantics a bit there if there can ever be more than one row matching AT.ApplicationId = @ApplicationId.

DECLARE @ApplicantId int

SET  @ApplicantId = (SELECT AT.ApplicantId ...

Would retain the original semantics and cause an error in that event.

Martin Smith
I knew it had to be something small! Thanks so much your a lifesaver.
Scott