Invalid Column Message

  • ALTER PROCEDURE Dbo.qrySubAddReadingsMeters (

    @varUser varchar(50),

    @varUtilRateType smallint=0)

    AS

    DECLARE @Select nvarchar(1000)

    SET @Select ='SELECT AR.Edit_Flag,AR.Meter_Key, UT.Util_Type + " " + M.Meter_Id as Meter, AR.Select_Flag

    FROM tblAddReadings AR, tblMeters M, tblUtilRates UR, tblUtilTypes UT

    WHERE AR.Meter_Key = M.Meter_Key

    AND M.Util_Rate_Key = UR.Util_Rate_Key

    AND UR.Util_Type_Key = UT.Util_Type_Key'

    SET @Select = @Select + char(13) + ' AND AR.FM_USer =' + @varUser 

    IF(@varUtilRateType >0) SET @Select = @Select + char(13) + ' AND UR.Util_Rate_Key =' + CAST(@varUtilRateType as nvarchar(5))

    SET @Select = @Select + char(13) + ' ORDER BY UT.Util_Type, M.Meter_ID'

    Exec(@Select)

     

    This line brings back an 'Inavalid Column Name' Message

    SET @Select = @Select + char(13) + ' AND AR.FM_USer =' + @varUser 

    Any Ideas??

    Thanks

    fryere

  • I got this to work in case anyone wondered.

    SET @Select = @Select + char(13) + ' AND AR.FM_USer ="' + @varUser +'"' 

     

    Thanks.

    fryere

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply