@var = TOP(@var) in SQL 2000

  • This is in SQL 2000. I need to select top (some) records from a view into a variable. I use:

    declare @lastzip varchar(8000)

    --@lastzip value obtained from another 'select' stmt

    select @zip = top (@lastzip) zipcode + ',' From vwSalesTeam v

    where v.userid = @userid order by zipcode asc

    I get an error

    Msg 170, Level 15, State 1, Procedure usp_search_ver5, Line 386

    Line 386: Incorrect syntax near '='.

    I was working in SQL 2005. I would have used the above code in SQL 2005. But now I'm using 2000 and I'm getting this error.

    Could anyone tell me what I'm doing wrong here???

    Any ideas/Suggestions are highly appreciated.

    Thanks

    Vijeya Shobana

  • Please don't cross-post.

    This thread is continued here:http://qa.sqlservercentral.com/Forums/Topic564222-8-1.aspx

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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