How to Import and Export SQL Server Database?
Last Updated :
16 Aug, 2024
Creating and managing a SQL Server database is an essential skill for database administrators and developers. In this article, We will go through the process of setting up a database in SQL Server, from creating the database and tables to inserting records, and finally, exporting and importing the database for backup or transfer purposes.
Creating and Managing a SQL Server Database
Step 1: Open the  "Microsoft SQL Server" Click on "File", and "New" and select "Database Engine Query".
Step 2: Create a Database
Query : Â
CREATE DATABASE college;
Output:

Step 3: Select the newly created table "college".
Query:Â
USE college;
Output:

Step 4: Creating a TableÂ
Query:
CREATE TABLE students( id INT NOT NULL PRIMARY KEY,
name VARCHAR(300) NOT NULL , reg _no INT NOT NULL ,
semester INT NOT NULL );
Output:

Step 5: Insert the RecordsÂ
Query:Â
INSERT INTO students VALUES
(1,'priya',31,3),(2,'keerthi',12,1),
(3,'rahul',29,2),(4,'reyansh',38,3),
5,'lasya',47,2);
Output:

Steps to Export SQL Server Database:
After creating a database in  "Microsoft SQL Server", Let's see how exporting takes place.
Step 1: Open the Object Explorer, Right-click on the Database that you want to export and click the "task" option and select  "Export Data-Tier Application".Â
         Â

Step 2: Click Next and by browsing, select the destination folder in which you have to save the database file. The filename should be as same as the database name ( here "college" ) and click "Next " and "Finish". You will get a dialogue box showing the result of exporting.

Steps to Import SQL Server Database
Step 1: Right Click on the Database folder and select "Import Data-Tier Application" and click "Next.

Step 2: Select the file which we have exported and change the name of the databaseÂ

 here we changed the database name from "college" to "college_ info" and click "Next" and a dialogue box appears showing the result of importing.
Conclusion
By following this guide, you have successfully created and managed a SQL Server database, including the steps to export and import the database. These foundational skills are crucial for maintaining and transferring data in SQL Server, ensuring that your databases are well-organized and easily accessible.
Similar Reads
How to Import and Export SQL Server Data to an Excel File? SQL Server is very popular in Relational Database and it is used across many software industries. Portability of data is a much-required feature of any database. i.e. Database should support features like exporting database data to Excel/CSV/JSON and also should import data from them. In this articl
3 min read
How to Open a Database in SQL Server? Opening a database in SQL Server is a fundamental task for database administrators and developers. It involves establishing a connection to the server instance and selecting a database to work with. In this article, we will explore two methods to open a database in SQL Server such as using SQL Serve
3 min read
How to Export Database and Table Schemas in SQLite? Exporting database schemas in SQLite is an important task for database management, enabling functions like data backup, recovery, migration, and auditing. In this article, We will go through the process of exporting database and table schemas in SQLite by understanding various examples to manage SQL
4 min read
How to Export MySQL Database using Command Line? Exporting MySQL databases using the command line utility in Windows is a knowledge every Database Administrator and developer should possess. The mysqldump utility is an easy-to-use program that can back up databases, replicate or transfer data from one server to another and migrate databases. In th
4 min read
How to Get SQL Server Database Size The ability to keep track of our SQL Server databases is very important to maintaining our storage resources effectively and within the proper performance limits. Knowing how large databases are can put us in a position to set up storage capacity which indicates the beginning of solving issues relat
3 min read
How to Get Database Size in SQL SQL database size is important for effective management. It indicates the storage space occupied by tables, indexes, and other components. Knowing the size of a database is useful for various purposes, such as monitoring the growth, estimating the backup time, planning the storage capacity, and opti
7 min read