SQL Data Compare 10

Help for older versions available.

These pages cover SQL Data Compare 10, which is not the latest version. Help for other versions is also available.

Cleaning up a SQL script after SQL Compare or SQL Data Compare

If you have produced a SQL script and you want to edit it by removing lines relating to certain databases or users for example, then you can use a simple DOS command to do all the tricky work for you in one line.

Create a DOS batch file the contents being as follows:

  1. findstr /v <string to be removed> <inputfile> > temp.txt
  2. move /y temp.txt <inputfile>

So to remove any lines containing 'sp_addrolemember' in a file called test1.sql the batch file will contain:

  1. findstr /v sp_addrolemember test1.sql > temp.txt
  2. move /y temp.txt test1.sql

Therefore if test1.sql starts off containing these lines: 

  1. EXEC sp_addrole N'roleMCEStore'
  2. EXEC sp_addrolemember N'roleMCEStore',N'PROD\svcMCEStore'
  3. GO

Run the batch file and test1.sql will now contain:

  1. EXEC sp_addrole N'roleMCEStore'
  2. GO

By typing findstr /? you will reveal the large number of options available for pre or post SQL processing.


Didn't find what you were looking for?