• Cannot agree more, nice and handy.

    I just wanted to say that it is neater to use EXEC in front of the stored procedure rather than GO at the end, so that the code may look like this:

    declare @OldOwner varchar(100)

    declare @NewOwner varchar(100)

    set @OldOwner = 'sys'

    set @NewOwner = 'dbo'

    select 'EXEC sp_changeobjectowner ''[' + table_schema + '].[' + table_name + ']'', ''' + @NewOwner + '''' 

    from information_schema.tables where Table_schema = @OldOwner

    and the output may look like this:

    EXEC sp_changeobjectowner '[sys].[author]', 'dbo'

    EXEC sp_changeobjectowner '[sys].[OrderItem]', 'dbo'

    Just a very minor thing, thank you for the script. I used to do this using a cursor and PRINT command but it is much quicker this way.

    Thank you,

    Dmytro