Incorrect syntax near 'FASTFIRSTROW'. If this is intended as a part of a table hint

Discussion in 'Software' started by be0, Jan 22, 2009.

  1. be0

    be0 Corporal

    Hello my geek friends.

    I have an issue with a function that I created. The above error message tells me the line number. Not anywhere in my function is there a refference to FASTFIRSTROW. Here is the function:

    alterfunction fnc_Transfer_To_Assy (@item_number varchar(30), @incoming_qty smallint)
    --FUNCTION WILL DETERMINE AT RUNTIME THE QTY OF AN ITEM THAT NEEDS TO BE TRANSF. TO ASSEMBLY
    --IMPORTANT IS TO REALIZE THAT THE DATA IS LOOKED AT RUN TIME.
    returns nvarchar(64)
    as
    begin

    Declare @Result nvarchar(64)
    declare @TotalOnHand int
    declare @QtyInspectAllocToContainer int
    declare @Count int
    declare @CursorItemNumber char(15)
    declare @CursorQtyOrdered decimal(13,4)
    declare @Found smallint
    declare @AssyTotal int
    set @AssyTotal = 0
    set @Found = 0
    set @Count = 0
    Set @CursorQtyOrdered = 0
    set @QtyInspectAllocToContainer = 0
    SET @item_number =upper(@item_number)

    SELECT @incoming_qty = @incoming_qty +convert(int,ISNULL(actual_qty, 0))from t_stored_item where item_number = @item_number
    and status <>'H'

    select @QtyInspectAllocToContainer =isnull(sum(actual_qty),0)from t_stored_item itm innerjoin t_location loc on loc.location_id = itm.location_id
    where itm.status <>'H'and itm.type <>'STORAGE'and loc.type <>'F'and itm.location_id notlike'OUT%'and itm.item_number = @item_number
    and loc.zone <>'OFF SITE'
    SET @incoming_qty = @incoming_qty - @QtyInspectAllocToContainer

    declare Open_orders CURSORfor
    select item_no, qty_ordered from HLICLV07.DATA.dbo.OEORDLIN_SQL
    where(item_no =UPPER(ltrim(rtrim(@item_number)))collate Latin1_General_BIN or(item_no likeUPPER(ltrim(rtrim(@item_number)))+'%'collate Latin1_General_BIN and prod_cat like'6%'))
    and ord_type in('I','O')
    open Open_orders
    fetch next from Open_orders into
    @CursorItemNumber, @CursorQtyOrdered

    while@@fetch_status= 0 and @Found = 0
    begin
    set @Count = @Count + @CursorQtyOrdered
    ifpatindex('%-%', @CursorItemNumber)> 0
    set @AssyTotal = @AssyTotal + @CursorQtyOrdered
    --IF AN ITEM IS -ESDS then add this qty to the assemly qty
    if @Count > @incoming_qty --case where I am above what is coming in at current itteration
    begin
    ifpatindex('%-%', @CursorItemNumber)> 0 --I am above and I dont have enough for transwer to ASSY.
    begin
    set @Result ='PLEASE CHECK FOR TRANSFERS TO ASSY.'
    set @Found = 1
    break
    end
    else
    begin
    set @Result ='TRANSFER '+convert(nvarchar, @AssyTotal)+' TO ASSY.'
    set @Found = 1
    break
    end
    end

    end
    close Open_orders
    deallocate Open_orders

    if @Found = 0
    begin
    set @Result ='TRANSFER '+convert(nvarchar, @AssyTotal)+' TO ASSY.'
    end

    return @Result
    end
     
  2. PC-XT

    PC-XT Master Sergeant

    Re: Incorrect syntax near 'FASTFIRSTROW'. If this is intended as a part of a table hi

    I think this is only a problem on newer servers, 2005+. They changed syntax, (making it more strict,) so old code that used to work broke:
    http://social.msdn.microsoft.com/Fo.../thread/6af86d8f-f049-444e-9936-d5b820117635/
    If you use old subprocedures, at least one of them probably needs changing. Here is a problem like yours, with FASTFIRSTROW not in the code: http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server/50146/query-fails-under-SQL-2005-64bit
    Here are other links about it:
    http://www.eggheadcafe.com/software/aspnet/31278881/cannot-declare-a-cursor-t.aspx
    http://www.eggheadcafe.com/software/aspnet/32530480/query-fails-under-sql-200.aspx
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds