SQL Script to Change Database Owner of All Databases

Microsoft Dynamics GPWhen moving databases between servers, you need to make sure the databases are set to have an owner of DYNSA. Rather than dong this individually, the below script can be run against the system database to generate a script you can then run to update the db owner.

Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
SELECT 'USE [' + DB_NAME() + ']
	sp_changedbowner ''DYNSA''
	SELECT 'USE [' + ['Company Master'].INTERID + ']
		sp_changedbowner ''DYNSA''
		SY01500 AS ['Company Master']

This script doesn't get the logical file name, but I've hooked it into the series I did on Logical File Name SQL Scripts as it will often be needed at the same time.

Can ISC Software Solutions help?

ISC Software Solutions are UK and Ireland based experts on Microsoft Dynamics GP. If you'd like to speak to someone about support, consultancy, upgrades, implementation, development, GP Elementz add-ons or portals, or anything else Dynamics GP related, you can use the form below.

Your Name (required):
Your Email (required):
Enquiry message:

What should we write about next?

Your Name (required) -
Your Email (required) -

1 thought on “SQL Script to Change Database Owner of All Databases

Leave a Reply

Your email address will not be published. Required fields are marked *