Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I "connect to the master database" (Azure SQL Database)

(This is for an Azure SQL Database)

Just about every article says at the start to "connect to the master database" before creating a new DB.

I have connected to my Azure SQL Database server with SSMS 2014 with no problems. I see the master DB under System Databases. I right-click on Databases (this is above System Databases) in the tree on the LHS and click New Database...

The template query comments area says among other things "...connect to master..." which implies to me that I am not connected to the master.

I am obviously missing something very fundamental and obvious regarding basics.

Can someone please put me out of my misery :)

PS When I click "New Database..." when connected to my non-Azure SQL Server 2012 I get a GUI and I am able to create a DB no problem.

like image 876
ThomasAJ Avatar asked Jul 25 '15 04:07

ThomasAJ


2 Answers

You do not need to explicitly connect to master to create a database in Azure SQL DB. Please follow the steps here to create a database in Azure SQL DB.

https://azure.microsoft.com/en-us/documentation/articles/sql-database-get-started/

Also, can you please give me links to the articles that mention "Connect to master" so I can take a look and correct them if needed? Thanks.

like image 53
Shantanu Avatar answered Nov 15 '22 06:11

Shantanu


I believe you are referring to the below template. You are actually connected to the master database and this is just a template instructions. If you are in doubt query select db_name() This should return 'master' for the master database.

If your connection string either specified database name as master / nothing it will be connected to master database.

-- ==========================================================================================================

-- Create database template for Azure SQL Database

-- This script will only run in the context of the master database. To manage this database in -- SQL Server Management Studio, either connect to the created database, or connect to master.

like image 43
Sirisha Chamarthi Avatar answered Nov 15 '22 06:11

Sirisha Chamarthi