Changing the default database for a SQL Azure login

Lorin H picture Lorin H · Jan 14, 2012 · Viewed 33k times · Source

I would like to change the default database for a login to support software that can access SQL Azure but does not allow easy alteration of a connection string. It appears that SQL Azure defaults to the master database.

I've already considered:

  • Stored procedures. I can't find a stored procedure that does this (sp_defaultdb is not implemented in SQL Azure as far as I can tell)

  • Alter Login. ALTER LOGIN does not permit the DEFAULT_DATABASE option.

  • SSMS. SSMS doesn't seem to allow much user control through the interface for SQL Azure.

Ideas?

Answer

t_yamatoya picture t_yamatoya · Jan 14, 2012

Connection String:

Server=tcp:[serverName].database.windows.net;Database=myDataBase;User ID=[LoginForDb]@[serverName];Password=myPassword;Trusted_Connection=False;Encrypt=True;

You can change connect default database, when you write 'Database' property at connection string.

SSMS is connect to database box which is option->secont tab at conecct dialog.