DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Which Tool Is Better for Code Completion — Azure Data Studio or dbForge SQL Complete?
  • Microsoft Azure Backup Service
  • Simplify Database Geo-Redundancy Backup With Cloud Storage Services
  • How to Build Your Exchange Server Recovery Strategy to Overcome Ransomware Attacks

Trending

  • The Ultimate Guide to API vs. SDK: What’s the Difference and How To Use Them
  • Message Construction: Enhancing Enterprise Integration Patterns
  • How To Aim for High GC Throughput
  • How To Handle Technical Debt in Scrum
  1. DZone
  2. Data Engineering
  3. Databases
  4. How Do You Export a Database in Azure Data Studio?

How Do You Export a Database in Azure Data Studio?

Let's explore how you can export a database with Azure Data Studio.

Grant Fritchey user avatar by
Grant Fritchey
·
Feb. 26, 19 · Tutorial
Like (3)
Save
Tweet
Share
43.90K Views

Join the DZone community and get the full member experience.

Join For Free

I’ve been writing a bunch about Azure Data Studio. I’ve also been recording videos on the topic. A comment I received recently asked how to export a database from Azure Data Studio. It made me want to explore the topic of exporting a database as it relates to Azure Data Studio.

Export?

When we say export, what exactly do we mean? It could be as simple as exporting data to a flat file for consumption in Excel or something. It could be creating a backup. Maybe we mean creating a bacpac file. We could also be looking at creating individual scripts for objects within the database. Finally, what about a full export of the database object definitions? Any or all of these could be what the question was about. So, let’s quickly address them each.

Each of these could be a manual process or an automated process. Instead of trying to address all of these at the same time, I’m going to break them down to individual steps, unique to Azure Data Studio, and then summarize with a section on automation at the end.

Flat File Export

While there is an Extension that lets you import flat files, there is not yet a tool for reversing that process within Azure Data Studio. However, that doesn’t mean that there isn’t a way to get this done. Let’s say we want to get some data out to Excel and we can define a query (which intentionally has a * because we want to export all the columns):

Transact-SQL:

SELECT *
FROM Sales.SalesOrderHeader AS soh
JOIN Sales.SalesOrderDetail AS sod
ON soh.SalesOrderID = sod.SalesOrderID
WHERE soh.OrderDate > '2014-06-26';


If we execute the query within Azure Data Studio, the results will look something like this (click to make bigger):

Image title


If you look all the way over to the right side of the screen, you’ll see this:

These are the export icons. In order, they are;

  • Save as CSV
  • Save as Excel
  • Save as JSON
  • Save as XML
  • Chart

In short, there’s a pretty easy way to get a result set out to a flat file in a variety of formats.

Backup

This topic is pretty short. It’s SQL Server. Even though I’m running these examples against a Linux container in Docker, a backup is a backup is a backup. Scripting a backup in SQL Server doesn’t change a lick. There is a built-in backup utility in Azure Data Studio. Right click on a database and select Backup from the context menu (not at all dissimilar to working in SQL Server Management Studio). You’ll get a new window that looks like this (again, click to make bigger):


Image title

I’m not going to run through all of that. It’s a backup. You can see that all the standard settings for a backup are available. Finally, you can choose to either run the backup defined within the window or you can script it out.

BACPAC

I’m not a fan. However, the bacpac is one method of extracting a database definition or exporting an entire database, so it’s worth discussing. To get this functionality, you will need to install the SQL Server Import extension.

With that installed, you will see a couple of new context menus. The one we’re interested in is the “Data-tier Application Wizard.” That will open the following:

There are two choices that interest us. First is the “Extract a data-tier application…” This wizard will extract a dacpac that will contain all the structures of your database but not the data. The second is the “Export the schema and data from a database…” wizard. This will create a bacpac, which is a dacpac, plus data. Extracting everything we need.

T-SQL Scripts

You also have the ability to create scripts. Within Azure Data Studio, right click on any object and the context menu will include “Script as Create.” This will generate your standard T-SQL script for the object in question. What you don’t get, at least that I’ve found, is any way to generate scripts for multiple objects.

Automating Export

Everything we’ve looked through so far, except for backups, has been GUI-driven stuff. So, where’s the automation for all this? The simple answer is, the same place it’s always been. You’ll write T-SQL for the things controlled within the database, just as you’ve always done. You’ll write PowerShell for everything else. That’s it. No real magic as such. However, if you are looking to automate the process through PowerShell (which I strongly, STRONGLY, recommend), there’s nothing wrong with a little cheating. Go and get the DBA Tools and use them to make your life a lot easier.

Conclusion

Azure Data Studio does include graphical mechanisms for exporting either data or objects from within the databases on your instances. However, nothing it introduces is actually new or different simply because you’ve always had the capacities that Azure Data Studio exposes. It just shows you different ways to get the export done.

Database Data (computing) azure Backup

Published at DZone with permission of Grant Fritchey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Which Tool Is Better for Code Completion — Azure Data Studio or dbForge SQL Complete?
  • Microsoft Azure Backup Service
  • Simplify Database Geo-Redundancy Backup With Cloud Storage Services
  • How to Build Your Exchange Server Recovery Strategy to Overcome Ransomware Attacks

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: