How to Import Data from Script File into SQL Server
Hello everyone, in the previous articles, I have been with you to install SQL Server, create a connection to SQL Server through SSMS (SQL Server Management Studio) and learn about some basic operations with SQL Server. already.
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.
#2. Create new database
First, you connect to the SQL Server database through SSMS as I have instructed in previous posts.
Then create a new database by clicking Database => and selecting New Database… as shown below.
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.
Okay, so we already have a database called BikeStores. However, at this point our database is still empty and nothing.
#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.
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.
After opening, click Execute to compile that Script.
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.
You do the same with the 3rd file (Load data) which will add sample data to the database tables.
Continue to click Execute to compile the Script.
You can observe in the Returned Messages section as shown below that the data has been successfully added.
To check, you can open any table to see if the data has been added or not. Here I open the table production.categories
#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.
You should read it
- Instructions for importing JSON into Google Sheets
- How to create and run a PowerShell script file on Windows 10
- How to import data from photos into Excel
- How to convert PowerShell script file (.ps1) to .exe by IExpress on Windows 10
- Secedit: import command in Windows
- How to copy styles between 2 Word files (Import, import styles from the old word file to the new file)
- How to Import Contacts from Excel File to Android Phone
- Upload File in PHP
May be interested
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 5part i and part ii of this series showed you how to install powershell and simple smo and wmi cmdlets. in part iii, i showed you how to script powershell and connect to sql server. in part iv, i will show you how to use the powershell script to loop through the contents of the file and connect it
- The best SFTP server and tools for secure file transfersftp prevents the transfer of unencrypted and simultaneous login information, it also creates a unique identifier, which must be retransmitted from the client to complete the data transfer.
- Tricks to import data in Excel fastestfrequently use excel to enter data, calculate and process data. if you enter data faster, the time spent on calculating and processing data will be more. there are many faster ways to import excel data that you can use.
- Instructions for setting up individual FTP Server with FileZillaunlike http - designed to forward hyper - text data over tcp connections, standard ftp ensures that the server responds to requests as soon as it receives a signal from the host. not only provides fast and accurate file transfer, but also security, gives users more options in the process of downloading and uploading data ...
- How to import Excel data into Python scripts with Pandasinstead of manually copying data into a database, here is a quick guide on how to load excel data into python using pandas.
- Automatically backup web server data with WinSCP via FTPfor website system administrators, data backup and recovery must always be the top priority. and in fact, there are many ways to do this that are applied daily. in the following article, we will show you how to do this with the free winscp tool and a little knowledge.
- How to import passwords from CSV file into Google Chromeif you already have passwords in a csv file and want to import them into chrome, you can easily do this in the google chrome browser.
- How to import and export OVA files in Virtualboxvirtualbox has a graphical application that you can use to create and manage your virtual machines easily on a desktop or workstation.
- Data types in SQL Serverbelow are the data types (data types) in sql server, including character strings, numbers and times / dates.
- Query XML data from a table with XML data typethis article illustrates how to create an xml schema, create a table with an xml data type, import an xml file into a table with an xml data type, query the xml file, and produce the same result as the actual result set. shown by sql transact commands.