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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
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

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Recovering an MS SQL Database From Suspect Mode: Step-By-Step Guide
  • 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

Trending

  • What Is Plagiarism? How to Avoid It and Cite Sources
  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • Simplifying Multi-LLM Integration With KubeMQ
  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.

By 
Grant Fritchey user avatar
Grant Fritchey
·
Feb. 26, 19 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
55.6K 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

  • Recovering an MS SQL Database From Suspect Mode: Step-By-Step Guide
  • 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

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • 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:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!