Updating a user's default organization using sql

Microsoft CRM has a nice feature where you can access the CRM website by using a short name (the name of the server running the CRM website). So for example, if you type http://crm into your browser CRM will then re-direct you to the longer URL: http://crm/nameofyourorganization/main.aspx.

This feature gets tricker if you have more than one organization (for example, if you have a test organization and a real organization).

The Organization that is retrieved when a user accesses the CRM website depends on the sequence in which the user was added to the Organizations. A user's default organization is the organization that the user was first created in.

So when you type http://crm/ into a browser, it will re-direct you to the user's first organization.

There is no built in feature to change a user's default organization. But you can do it if you have the on-premise version of CRM and thus you have access to the SQL Server database.

You can query each user's default organization by running this against the MSCRM_CONFIG database:

select * from systemuser

To change someone's default organization, run this:

update systemuser set defaultorganizationid ='xxxxx'

You have to know the organization id to use instead of 'xxxxx'. To determine that, run this:

select * from organization