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. @@rowcount is now working with while and if statement

@@rowcount is now working with while and if statement

Scheduled Pinned Locked Moved Database
sharepoint
3 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.
  • J Offline
    J Offline
    Jagz W
    wrote on last edited by
    #1

    I have created a sp in which i have used @@rowcount with while but it is not working e.g Select * from #temp print @@rowcount while @@rowcount <> 0 begin ---- ---- --- end the print command is giving rowcount 1 but still it is not working

    One person's data is another person's program. --J.Walia

    G 1 Reply Last reply
    0
    • J Jagz W

      I have created a sp in which i have used @@rowcount with while but it is not working e.g Select * from #temp print @@rowcount while @@rowcount <> 0 begin ---- ---- --- end the print command is giving rowcount 1 but still it is not working

      One person's data is another person's program. --J.Walia

      G Offline
      G Offline
      Goutam Patra
      wrote on last edited by
      #2

      Remove that print @@rowcount or declare a variable and set the @@rowcount into that variable and use that variable further.

      DECLARE @rc AS INTEGER
      Select * from #temp
      SET @rc = @@rowcount
      print @rc
      while @rc <> 0
      begin



      end

      C 1 Reply Last reply
      0
      • G Goutam Patra

        Remove that print @@rowcount or declare a variable and set the @@rowcount into that variable and use that variable further.

        DECLARE @rc AS INTEGER
        Select * from #temp
        SET @rc = @@rowcount
        print @rc
        while @rc <> 0
        begin



        end

        C Offline
        C Offline
        Corporal Agarn
        wrote on last edited by
        #3

        This is because the @@ values get reset when an action (print) executes.

        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