Sql-server – SQL Server database generate script how to avoid adding PRINT statements

scriptingsql-server-2008-r2

I need to create Insert scripts from the content of a table. To do that, I used the database tasks -> generate scripts.

The table is quite big and in the generated script, it adds PRINT command after each 100 number of rows and a GO statement. For example:

print 'Processed 9200 total records'
GO

For some reasons I can't have GO and PRINT command in the script, repeated in the middle. Is there any way to avoid creating them in the generated script? It is really time consuming to go one by one and delete all PRINT xxxx statements.

Thanks.

Best Answer

I would not remove the GO statements that break up large batches. There are various reasons for breaking large inserts

  1. size (duration) of transactions
  2. memory requirements
  3. transaction log management
  4. mirror synchronicity
  5. error isolation (by batch)
  6. etc...

As for removing the status updates, that can be done easily. Press Ctrl-H or from the menu, Edit -> Find and Replace -> Quick Replace, fill it in as shown in the image below making sure to tick "Use" Regular Expressions, then click on "Replace All" to zap them all.

Remove PRINT updates