Service Broker Table Copy, file send?

Hi There

I have a table at my initiator, i have a copy of this table at my target, every morning i want to refresh the table at the target with the data from the initiator via service broker.

What would be the best way to do this

One major consideration would be that this table would be very large +- 1.6 million rows.

I was thinking of exporting the table to file like a csv, compressing the file and then sending it via service broker. Then at the target i would uncompress and bulk copy the data into the table at the target.

But can this be done

How would one go about sending a file via service broker

For example if i wanted to send a .csv or something via service broker how would i do it

I know i can send binary data, but i would have to equate the msg to a file on disk, and how exactly would a recieve this file on the other side and make sure it went to disk at the target, i am guessing it is a mixture of xp_cmdshell and service broker.

Can this work

Or is there a much simpler way Any thoughts would be appreciated.

Thanx



Answer this question

Service Broker Table Copy, file send?

  • Jonas.S

    Hi Rushi

    I believe i have found a better way, i use openrowset to read a compressed file from disk into a varbinary(max) variable, however i have not tried to send this yet as a binary message, or reverse the message back to disk at the target. I will probably only get around to testing this next week, i will then post back with the results.

    Thank You


  • Mikey The Pikey

    Why not use SQL Replication Services
  • Itzik Katzav

    Using the .NET framework libraries, you can open the file on disk, read the bytes and execute a SEND statement via the in-proc CLR provider.
  • mxiong

    Using a CLR stored proc would be safer than xp_cmdshell.
  • ted944

    Hi Rushi

    May reason i dont want to go into, we cannot use replication.

    So staying away from xp_cmdshell vs clr, how do you equate a borker message to a file on disk, or send a file on disk as a broker message

    Thanx


  • Service Broker Table Copy, file send?