SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Best way to handle moving data in a varchar(max) field?


Best way to handle moving data in a varchar(max) field?

Author
Message
ManicStar
ManicStar
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15837 Visits: 6019
Any ideas how to efficiently move a lot of rows from a table in the OLTP to an archive on another server when that table contains a varchar(max)? My SSIS package just spins and spins on these, even after setting rows per batch and max insert commit size kinda small to keep batching small.

The archive database is set to simple recovery model, would bulk load be better?

Is BCP worth looking at?
Eirikur Eiriksson
Eirikur Eiriksson
SSC Guru
SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)

Group: General Forum Members
Points: 164696 Visits: 23881
ManicStar - Tuesday, February 13, 2018 9:07 AM
Any ideas how to efficiently move a lot of rows from a table in the OLTP to an archive on another server when that table contains a varchar(max)? My SSIS package just spins and spins on these, even after setting rows per batch and max insert commit size kinda small to keep batching small.

The archive database is set to simple recovery model, would bulk load be better?

Is BCP worth looking at?

What is the actual size of the data (datalength)?
Cool

ManicStar
ManicStar
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15837 Visits: 6019
Eirikur Eiriksson - Tuesday, February 13, 2018 9:25 AM
ManicStar - Tuesday, February 13, 2018 9:07 AM
Any ideas how to efficiently move a lot of rows from a table in the OLTP to an archive on another server when that table contains a varchar(max)? My SSIS package just spins and spins on these, even after setting rows per batch and max insert commit size kinda small to keep batching small.

The archive database is set to simple recovery model, would bulk load be better?

Is BCP worth looking at?

What is the actual size of the data (datalength)?
Cool

Close to a meg for the largest one. They are comments and call notes, so some of them are very long.

Eirikur Eiriksson
Eirikur Eiriksson
SSC Guru
SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)SSC Guru (164K reputation)

Group: General Forum Members
Points: 164696 Visits: 23881
ManicStar - Tuesday, February 13, 2018 9:31 AM
Eirikur Eiriksson - Tuesday, February 13, 2018 9:25 AM
ManicStar - Tuesday, February 13, 2018 9:07 AM
Any ideas how to efficiently move a lot of rows from a table in the OLTP to an archive on another server when that table contains a varchar(max)? My SSIS package just spins and spins on these, even after setting rows per batch and max insert commit size kinda small to keep batching small.

The archive database is set to simple recovery model, would bulk load be better?

Is BCP worth looking at?

What is the actual size of the data (datalength)?
Cool

Close to a meg for the largest one. They are comments and call notes, so some of them are very long.

Not certain why the SSIS isn't working properly, those are not large chunks of data. What is the volume/time (number of entries) that you need to transfer?
One option is to offload the content into a local staging table before the transfer if the source table is busy or cluttered with lock escalation etc.
Cool

Subramaniam Chandrasekar
Subramaniam Chandrasekar
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3666 Visits: 531
ManicStar - Tuesday, February 13, 2018 9:31 AM
Eirikur Eiriksson - Tuesday, February 13, 2018 9:25 AM
ManicStar - Tuesday, February 13, 2018 9:07 AM
Any ideas how to efficiently move a lot of rows from a table in the OLTP to an archive on another server when that table contains a varchar(max)? My SSIS package just spins and spins on these, even after setting rows per batch and max insert commit size kinda small to keep batching small.

The archive database is set to simple recovery model, would bulk load be better?

Is BCP worth looking at?

What is the actual size of the data (datalength)?
Cool

Close to a meg for the largest one. They are comments and call notes, so some of them are very long.

You could try to insert the varchar(max) field as NULL first and later update them with actual data. this way you can finish the actions soon.

frederico_fonseca
frederico_fonseca
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10762 Visits: 5900
Don't use SSIS for that as it sucks with LOB types.

Powershell or C# (can be inside a SSIS package script task if you prefer) with a sql reader and a sqlbulkcopy will be the best options.

But it can still be slow to copy - but not as slow as SSIS as it saves each blob on local disk as part of the process.

small example - https://www.codeproject.com/Articles/18418/Transferring-Data-Using-SqlBulkCopy
do remove the notifyafter and the sqlrowscopy bit as it only slows it down
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)

Group: General Forum Members
Points: 896451 Visits: 48256
Heh... so what's wrong with a simple INSERT/SELECT???

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

When you put the right degree of spin on it, the number 318 is also a glyph that describes the nature of a DBAs job. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
frederico_fonseca
frederico_fonseca
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10762 Visits: 5900
Jeff Moden - Thursday, March 1, 2018 7:38 PM
Heh... so what's wrong with a simple INSERT/SELECT???


Didn't mention this one as this is across servers and linked servers can behave poorly with blobs
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)

Group: General Forum Members
Points: 896451 Visits: 48256
frederico_fonseca - Friday, March 2, 2018 2:29 AM
Jeff Moden - Thursday, March 1, 2018 7:38 PM
Heh... so what's wrong with a simple INSERT/SELECT???


Didn't mention this one as this is across servers and linked servers can behave poorly with blobs

Hmmmm... looking back, I don't know if it does or not because I've not had the need, yet, and so haven't actually tried. I'll have to give that a try at work. Thanks for the tip.

Shifting gears a bit, there are even more ways to skin the same cat. For example (and as the OP asked in the original post), you could also use a "native" BCP export on one side and either a BULK INSERT or "native" BCP import on the other side. It's already a "written" bit of functionality and it could be called from an SSIS task.

Another possibility is to set things up in a temporally based partitioned view where each partition is actually in a small database. If the small database files share common storage between the two servers (not uncommon for where I work at), it would be incredibly fast to rebuild the view at the source to exclude the partition to be moved and then detach the small database. The prompt the server on the other end to attach the small database and rebuild its partitioned view to include it. No data movement would actually occur which would make it comparatively lightning fast.

If the servers didn't share common storage, then perhaps a compressed backup and restore of the small partition database would fit the bill.


--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

When you put the right degree of spin on it, the number 318 is also a glyph that describes the nature of a DBAs job. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search