Doubt about CURSORS....!!!!!!!!!

  • Hi friends,

    If my under standing is correct , while declaring a CURSOR if we give INSENSITIVE option , the Cursor will create a temp table and the fetching of the data will be from this table so that the modification done on the base table wont reflect to the result set of the Cursor.

    My doubt is , if this is the case can we see this temp table in the temp db ? atleast is before closing and deallocating the Cursor?

    Please let me know if my understanding is not correct and also the answer for the doubt.

    Many thanks,

    MC

    Thanks & Regards,
    MC

  • The internal worktable created to hold a copy of the rows is not a normal temporary table and can't be accessed by users.

  • Oh is it so... Many thanks. Because in some article which I red about CURSOR, it was mentioned as "a temptable will be created in tempdb " , that is why I got this doubt.

    Once again thanks for your reply.

    Regards,

    MC

    Thanks & Regards,
    MC

  • I would like to mention that if you are going to use cursors (which can and should usually be avoided, btw) then in those cases where you just do a FETCH NEXT (which is almost always) you should use either FAST_FORWARD or LOCAL STATIC READ_ONLY FORWARD_ONLY. Hugo Kornelis (sp?) did a wonderful cursor performance analysis you can find online.

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

Viewing 5 posts - 1 through 4 (of 4 total)

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