Change db owner in sql server 2005 database.
Example DECLARE @old sysname, @sql varchar(1000) SELECT @old = 'oldOwner_CHANGE_THIS' , @sql = ' IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES WHERE QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?'' AND TABLE_SCHEMA = ''' + @old + ''' ) ALTER SCHEMA dbo TRANSFER ?' EXECUTE sp_MSforeachtable @sql