Ejecución de secuencia de comandos de inserción desde un archivo de texto grande (44 GB)

We have the below requirement, A large text file of size 44GB containing insert scripts for a table is given. We need to execute these scripts against target SQL server 2008 R2 database. We followed 2 step process to execute the scripts. 1. Bulk inserted all the insert statements into intermeditate table one by one(approx 22 million records). 2. Then executed the statements in the intermediate table using a cursor.

The first step is succeeding, however the second step is not so effective as it is slow and a few insert statements fail in the middle of execution. We are unable to locate the exact point of failure. Could you please let us know an effective way of accomplishing the task.

preguntado el 31 de julio de 12 a las 12:07

you're not running all that under a transaction are you ? -

1 Respuestas

Using a cursor is generally not recommended due to being slow and a memory hog. Try using a WHILE loop instead?

Ejemplo de referencia:

El procedimiento almacenado de SQL Server evita el cursor

contestado el 23 de mayo de 17 a las 12:05

Thanks for looking into this :) We had earlier tried using while statement :) and that was also not very effective. We have executed the script using cursor and loaded the data. now the problem is there are some syntax errors in the insert statements in table. We are figuring out the errors. There are about 1000 syntax errors randomly scattered in 22 million rows. - daniel peter

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.