Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Import Data from Script File into SQL Server

Learn how to import data from script file into SQL server with clear steps, practical tips, and troubleshooting advice for a smoother, more reliable.

Table of Contents

This practical guide walks through how to import data from script file into SQL server, explains the main requirements, and highlights common issues that may appear along the way.

In this next article, I will learn with you how to open and run a script file (file containing SQL statements) to create tables and Insert sample data into SQL Server through SQL Server. SSMS.

#first. Design of the database

Understanding and grasping the design of the database is a very important thing when you work with database management systems.

Below is the design of the sample database that I will use in this article. All has been written as Script. You can download the file here or here.

#first. Design of the database — How to Import Data from Script File into SQL Server

#2. Create new database

First, you connect to the SQL Server database through SSMS as I have instructed in previous posts.

#2. Create new database — How to Import Data from Script File into SQL Server

Then create a new database by clicking Database => and selecting New Database… as shown below.

#2. Create new database — How to Import Data from Script File into SQL Server

Because in the Script I have defined the database name as BikeStores, so in the Database name section, you should set it to BikeStores to avoid Script compilation errors.

=> After naming, click OK to continue.

#2. Create new database — How to Import Data from Script File into SQL Server

Okay, so we already have a database called BikeStores. However, Next our database is still empty and nothing.

#2. Create new database — How to Import Data from Script File into SQL Server

#3. Open and run Script files in SSML

Next we will open the Script and run it to add the tables and sample data to the newly created database.

Implementation: You go to File => select Open => and select File as shown below. Or you can use the key combination CTRL + O for fast.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

The first Script (Create Objects) will be the Script used to create the tables in the database. You will open and run this file first to create the tables in the database.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

After opening, click Execute to compile that Script.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

And now in the Tables section you will see that all the tables as shown in the design have been successfully created, in addition, there will be a message with the content Commands completed successfully in the Messages section.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

You do the same with the 3rd file (Load data) which will add sample data to the database tables.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

Continue to click Execute to compile the Script.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

You can observe in the Returned Messages section as shown below that the data has been successfully added.

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

To check, you can open any table to see if the data has been added or not. Here I open the table production.categories

#3. Open and run Script files in SSML — How to Import Data from Script File into SQL Server

#4. Epilogue

Okay, the process of importing data from into SQL Server Management Studio is also relatively simple, isn't it.

Through this article, I believe you already know how to use Script files to create tables as well as add data to the database in SQL Server, right!

In fact, when doing a project, one can export a Database (Export) into a Script file that can be carried to other machines to run very conveniently.

Okay, see you in the next articles about SQL Server.

Key Takeaways

Use the information above as a practical reference for how to import data from script file into SQL server. Review each step carefully, confirm any requirements, and choose the option that best fits your situation.

FAQ

What does this guide explain about Import Data from Script File into SQL Server?

It explains the main concepts, practical considerations, and useful steps related to import data from script file into SQL server without requiring advanced knowledge.

Who can benefit from learning about Import Data from Script File into SQL Server?

This information is useful for readers who want a clear overview, practical guidance, and reliable steps related to import data from script file into SQL server.

What should I check before applying this information?

Review the requirements, confirm that your device, software, or situation matches the instructions, and back up important data before making major changes.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.