Skip to content
Advertisement

How to Insert Large Amount of Varbinary(max) Rows Into Table

I use a local SQL Server. I have table with 250k of photos (DropPhotos). Photos are stored in a Varbinary(max) column which is called Content. I want to move all of this rows into another table within same database (BasePhotos) along with some additional columns. I wrote SQL statement like this:

When I start execution everything goes normal. After several minutes (5 – 15 mins) my screen starts to turn on and off randomly, then it turns off and after several more minutes my pc goes into reboot. I suspect that moving so much binary data drains all of it RAM and leads to shutdown. I’ve searched online for solution and discovered that there is exist some kind of Bulk Insert. Maybe it could help me? But as far as I know it is used to insert rows from file, not from one table from another.

So my question is quite simple: How to approach inserting large amount of heavy rows into table.

PhotoId is uniqueidentifier

Advertisement

Answer

Update: Please note that OP is asking for moving records in the question, this was later changed to copying records in a comment.

The batch approach discussed above, may be implemented like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement