Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi everyone,

    I am trying to pass a selection of parameters to a cursor useing t-sql on MS Server 2005

    I am not sure how to do this, so far I have the following

    DECLARE cur_test CURSOR FOR
    SELECT @colA
    ,colB
    FROM tbl_test
    WHERE colC = @var1
    AND colD = @var2

    OPEN cur_test
    FETCH NEXT FROM Cur_test
    WHILE @@FETCH_STATUS = 0
    BEGIN
    -- other code will go here
    FETCH NEXT FROM Cur_test
    END

    CLOSE @CursorVar
    DEALLOCATE @CursorVar

    -- END CODE

    @var1 and @var2 do have values set to them, but I have something wrong with the way I am attempting to pass the WHERE clauses to the cursor

    Kind Regards
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Unfortunately very few of us that frequent this forum use SQL Server, and those who do mostly use ODBC links to SQL Server tables. I have very limited experience with stored procedures, and none with the use of cursors in them. I would suggest you try either one of the Microsoft forums on SQL Server, or one of the public ones such as SQLTeam.com, Tek-Tips.com or SQLServerCentral.com.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •