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. Wait until an operation finished

Wait until an operation finished

Scheduled Pinned Locked Moved Database
database
5 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.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    Hi Friends, I have a database on which I have enabled CDC on some tables. As CDC captures auditing data on transactions basis, I am accessing that data and putting in flat file by using a Store Procedure Now is there any way in T-SQL so that, we can wait until a transaction finishes to capture the data. Because if I capture the information half way we may miss some of the data.

    Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

    J 1 Reply Last reply
    0
    • I indian143

      Hi Friends, I have a database on which I have enabled CDC on some tables. As CDC captures auditing data on transactions basis, I am accessing that data and putting in flat file by using a Store Procedure Now is there any way in T-SQL so that, we can wait until a transaction finishes to capture the data. Because if I capture the information half way we may miss some of the data.

      Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

      J Offline
      J Offline
      John C Rayan
      wrote on last edited by
      #2

      Can't you use AFTER INSERT , AFTER UPDATE T-SQL (triggers) in this scenario? Am I missing something that you are not explaining in detail?

      I 1 Reply Last reply
      0
      • J John C Rayan

        Can't you use AFTER INSERT , AFTER UPDATE T-SQL (triggers) in this scenario? Am I missing something that you are not explaining in detail?

        I Offline
        I Offline
        indian143
        wrote on last edited by
        #3

        Sure, a trigger works on the Table level, where as I want it on the transaction level, on transaction may be using multiple tables. The other interesting and more complex thing is Change Data Capture works on log file asynchronously to write the values into Audit tables. But luckily CDC writes information as Transaction based, like it gives same start_lsn id for same transaction, which I can use. But for example when I retrieving data from CDC Audit tables and putting it in the Flat tables then I want to wait if CDC is in between writing a Transaction on to the CDC Audit tables. Can I do it? Thanks in advance.

        Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

        G J 2 Replies Last reply
        0
        • I indian143

          Sure, a trigger works on the Table level, where as I want it on the transaction level, on transaction may be using multiple tables. The other interesting and more complex thing is Change Data Capture works on log file asynchronously to write the values into Audit tables. But luckily CDC writes information as Transaction based, like it gives same start_lsn id for same transaction, which I can use. But for example when I retrieving data from CDC Audit tables and putting it in the Flat tables then I want to wait if CDC is in between writing a Transaction on to the CDC Audit tables. Can I do it? Thanks in advance.

          Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

          G Offline
          G Offline
          GuyThiebaut
          wrote on last edited by
          #4

          My suggestion - give each 'transaction' a GUID. Create a table that holds the GUIDs of 'transactions' that have been completed. Write the relevant GUID into this table when a 'transaction' is completed. Then when it comes to determining whether the data is ready to be sent to flat files just look to see if the GUID exists in your completed 'transaction' GUID table.

          “That which can be asserted without evidence, can be dismissed without evidence.”

          ― Christopher Hitchens

          1 Reply Last reply
          0
          • I indian143

            Sure, a trigger works on the Table level, where as I want it on the transaction level, on transaction may be using multiple tables. The other interesting and more complex thing is Change Data Capture works on log file asynchronously to write the values into Audit tables. But luckily CDC writes information as Transaction based, like it gives same start_lsn id for same transaction, which I can use. But for example when I retrieving data from CDC Audit tables and putting it in the Flat tables then I want to wait if CDC is in between writing a Transaction on to the CDC Audit tables. Can I do it? Thanks in advance.

            Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

            J Offline
            J Offline
            John C Rayan
            wrote on last edited by
            #5

            May be this is not direct solution for you but should give you some idea. sql server - Delayed availability of historical data when using CDC - Database Administrators Stack Exchange[^]

            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