• Here's a template for a generic cursor. See BOL for details.

    -----------------------------------------------------------

    -- to reduce traffic don't bother with display of row count

    set nocount on

    -- define the cursor --

    declare @object varchar(128)

    declare mycursor scroll cursor

    for

    -- the SQL --

    select SomeData from SomeTable

    -- traverse the cursor --

    open mycursor

    fetch first from mycursor into @object

    while @@fetch_status -1

    begin

    if @@fetch_status -2

    begin

    -- do the work here --

    print @object

    end

    fetch next from mycursor into @object

    end

    -- clean up --

    close mycursor

    deallocate mycursor

    -MarkO

    "You do not really understand something until you can explain it to your grandmother" - Albert Einstein