I have created the following SQL code to create a script to change the owner of a MS SQL Server database:

SQL Code:
  1. /*Change Owners of a table:*/
  2.  
  3. DECLARE @OldOwner CHAR(25)
  4. DECLARE @NewOwner CHAR(25)
  5.  
  6. SET @OldOwner ='dbo'
  7. SET @NewOwner = 'ADM'
  8.  
  9. SELECT 'exec sp_changeobjectowner ' + CHAR(39) + RTRIM(LTRIM(@OldOwner)) + '.' + _
  10.          Name + CHAR(39) +',' + CHAR(39)+ RTRIM(LTRIM(@NewOwner)) + CHAR(39) Owner_Change_Script
  11. FROM sysobjects
  12. WHERE xtype = 'U' AND UID = 5
  13. ORDER by Name

This code outputs the following:

SQL Code:
  1. exec sp_changeobjectowner 'dbo.CLASSES','ADM'
  2. exec sp_changeobjectowner 'dbo.CAUSES','ADM'
  3. exec sp_changeobjectowner 'dbo.LEVEL','ADM'
  4. exec sp_changeobjectowner 'dbo.ACCIDENTS','ADM'
  5. exec sp_changeobjectowner 'dbo.ACTIONS','ADM'


But I want the Script to insert a 'Go' in between each exec statement like this:

SQL Code:
  1. exec sp_changeobjectowner 'dbo.CLASSES','ADM'
  2. GO
  3. exec sp_changeobjectowner 'dbo.CAUSES','ADM'
  4. GO
  5. exec sp_changeobjectowner 'dbo.LEVEL','ADM'
  6. GO
  7. exec sp_changeobjectowner 'dbo.ACCIDENTS','ADM'
  8. GO
  9. exec sp_changeobjectowner 'dbo.ACTIONS','ADM'
  10. GO

But for the life of me I can't seem to figure it out. Any ideas how I can go about doing this??? The databases I have to convert have hundreds and hundreds of tables and when it throws an error I want to be able to click on the error and be brought to the line that threw the error.

Thanks!