0

How can I add a database to Azure Data Studio on Mac ?

I've created a SQL Image in Docker and I've connected Azure Data Studio to it. I'm trying to add an additional database. On Windows you would typically right clock on 'Database' and have the option 'New Database' but I don't seem to have that option on macOS. What am I doing wrong ? I have installed the 'SQL Database Projects' extension. I am trying to add an additional database

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • You don't "add" a new database to ADS; ADD is an IDE like environment. You add a new database to your instance of SQL Server. There are plenty of duplicates on how to do that, so what about all of those didnt you under? Where did you get stuck? – Thom A May 24 '23 at 04:20
  • The syntax for creating a new database (`CREATE DATABASE`) is ko different to if you are using SSMS or ADS either; did you try running the statement and seeing what happened? What error did you get? – Thom A May 24 '23 at 04:21
  • I came across this bit of code that actually solved my problem. USE master; GO IF NOT EXISTS ( SELECT name FROM sys.databases WHERE name = N'TutorialDB' ) CREATE DATABASE [TutorialDB]; GO IF SERVERPROPERTY('ProductVersion') > '12' ALTER DATABASE [TutorialDB] SET QUERY_STORE = ON; GO – internet_preferences May 27 '23 at 04:03

1 Answers1

0

Glad you solved it, posting it as an answer to help other community members.

To add new database on Azure data studio you can install Azure Data Studio onto your Mac connect to SQL server then create a new query and write SQL query to create a database.

enter image description here

Query to create an database:

--use master database
USE master; 
GO 
-- create TutorialDB database it not exist
IF NOT EXISTS ( SELECT name FROM sys.databases WHERE name = N'TutorialDB' ) CREATE DATABASE [TutorialDB]; 
Go

Also, you can refer this document to connect and query Microsoft SQL Server Docker Container with Azure Data Studio

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11