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. Web Development
  3. ASP.NET
  4. SQLBULKCOPY class - number of records copied

SQLBULKCOPY class - number of records copied

Scheduled Pinned Locked Moved ASP.NET
databasecsharpquestion
2 Posts 2 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.
  • S Offline
    S Offline
    sb_rs
    wrote on last edited by
    #1

    Hi, In one of the tasks, we are using sqlbulkcopy class of .net with three parameters - source db info, destination db info, query to be used to transfer data. We are trying to see if we can get a count of the number of rows that are actually transmitted by the above command. Is there any way to do that? sqlbulkcopy class does not seem to have any attribute that would give this information. Is there any direct or indirect way? Thanks in advance sb

    T 1 Reply Last reply
    0
    • S sb_rs

      Hi, In one of the tasks, we are using sqlbulkcopy class of .net with three parameters - source db info, destination db info, query to be used to transfer data. We are trying to see if we can get a count of the number of rows that are actually transmitted by the above command. Is there any way to do that? sqlbulkcopy class does not seem to have any attribute that would give this information. Is there any direct or indirect way? Thanks in advance sb

      T Offline
      T Offline
      Torsten Mauz
      wrote on last edited by
      #2

      Looking at the MSDN docs there's no nice way of doing this. Their examples all suggest doing a "pre-work" row count, then doing the BulkCopy, then doing a "post-work" row count (which will obviously give you the final count). http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx[^] There is an event fired SqlRowsCopied but it looks like it only fires after a fixed number of rows have been copied (so if you set the NotifyAfter property to 50 and copy 99 rows you'll only get notified once), although it might fire when it completes as well (I'll leave that for you to check). http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.sqlrowscopied.aspx[^] HTH

      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