Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sp_cursoropen - does not return rowcount

sp_cursoropen - does not return rowcount

Scheduled Pinned Locked Moved Database
sharepointhelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krishnraj
    wrote on last edited by
    #1

    Hi all, I made one procedure in which i use sp_cursoropen procedure and it has one parameter for rowcount. When i execute the procedure, it does not return rowcount, i mean it returns -1 even there is 20 records in my table. Can anybody help me... Thanks

    Krishnraj

    T W 2 Replies Last reply
    0
    • K Krishnraj

      Hi all, I made one procedure in which i use sp_cursoropen procedure and it has one parameter for rowcount. When i execute the procedure, it does not return rowcount, i mean it returns -1 even there is 20 records in my table. Can anybody help me... Thanks

      Krishnraj

      T Offline
      T Offline
      topcatalpha
      wrote on last edited by
      #2

      Hi Put return at the end of you're stored procedure declare @counter int select @counter = count(*) from mytable return @counter or set rowcount as output parameter and print it. or set nocount off greetz

      K 1 Reply Last reply
      0
      • T topcatalpha

        Hi Put return at the end of you're stored procedure declare @counter int select @counter = count(*) from mytable return @counter or set rowcount as output parameter and print it. or set nocount off greetz

        K Offline
        K Offline
        Krishnraj
        wrote on last edited by
        #3

        Hi topcatalpha, Thanks for reply, but sp_cursoropen has one parameter which returns the total count of table. so no need to fire extra query as u said. sp_cursoropen is sql server 2000's in built system procedure i think there may be some other settings. any way thanks buddy...

        Krishnraj

        1 Reply Last reply
        0
        • K Krishnraj

          Hi all, I made one procedure in which i use sp_cursoropen procedure and it has one parameter for rowcount. When i execute the procedure, it does not return rowcount, i mean it returns -1 even there is 20 records in my table. Can anybody help me... Thanks

          Krishnraj

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          With what parameters are you callin this sp. It would depend on the cursor type if the rowcount can be returned. For example if the cursor is forward only, AFAIK the actual rowcount cannot be determined.

          The need to optimize rises from a bad design. My articles[^]

          K 1 Reply Last reply
          0
          • W Wendelius

            With what parameters are you callin this sp. It would depend on the cursor type if the rowcount can be returned. For example if the cursor is forward only, AFAIK the actual rowcount cannot be determined.

            The need to optimize rises from a bad design. My articles[^]

            K Offline
            K Offline
            Krishnraj
            wrote on last edited by
            #5

            Hi Mika, Below is my query where u find variable @mainQuery. which is my table fetch query with Inner join with 3 tables.

            Declare @cursor int, @rowcount int

            Exec sp_cursoropen @cursor output,@mainQuery,16,8196,@rowcount output

            Select @rowcount

            Exec sp_cursorfetch @cursor,32,@RowNumber,@PageSize

            Exec sp_cursorclose @cursor

            Do u think that there may be a problem with inner join query? Thanks for replying...

            Krishnraj

            W 1 Reply Last reply
            0
            • K Krishnraj

              Hi Mika, Below is my query where u find variable @mainQuery. which is my table fetch query with Inner join with 3 tables.

              Declare @cursor int, @rowcount int

              Exec sp_cursoropen @cursor output,@mainQuery,16,8196,@rowcount output

              Select @rowcount

              Exec sp_cursorfetch @cursor,32,@RowNumber,@PageSize

              Exec sp_cursorclose @cursor

              Do u think that there may be a problem with inner join query? Thanks for replying...

              Krishnraj

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              No I don't believe that the inner join is the problem. Now you're using fast forward-only cursor. What happens if you change to keyset-driven cursor:

              Exec sp_cursoropen @cursor output, @mainQuery, 1, 8196, @rowcount output

              or dynamic cursor

              Exec sp_cursoropen @cursor output, @mainQuery, 2, 8196, @rowcount output

              The need to optimize rises from a bad design. My articles[^]

              K 1 Reply Last reply
              0
              • W Wendelius

                No I don't believe that the inner join is the problem. Now you're using fast forward-only cursor. What happens if you change to keyset-driven cursor:

                Exec sp_cursoropen @cursor output, @mainQuery, 1, 8196, @rowcount output

                or dynamic cursor

                Exec sp_cursoropen @cursor output, @mainQuery, 2, 8196, @rowcount output

                The need to optimize rises from a bad design. My articles[^]

                K Offline
                K Offline
                Krishnraj
                wrote on last edited by
                #7

                Hi Mika, Yes your answer is correct, inner join is not problem here. And as per u said, i used keyset-driven cursor then it gives me count.. :-D So its briliant suggesion... Thank you boss....:rose:

                Krishnraj

                W 1 Reply Last reply
                0
                • K Krishnraj

                  Hi Mika, Yes your answer is correct, inner join is not problem here. And as per u said, i used keyset-driven cursor then it gives me count.. :-D So its briliant suggesion... Thank you boss....:rose:

                  Krishnraj

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  You're welcome :)

                  The need to optimize rises from a bad design. My articles[^]

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups