In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about how to use bulkinsert. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
If you are working with a database, it may involve inserting data from an external data file into an inverted SQLServer. This article shows you how to use the BULKINSERT command to import data and how to insert data more easily and efficiently by changing some of the options of the command.
What is bulkinsert?
In SQLServer, BULKINSERT is a T-SQL command used to load external files into database tables in a specific format. This command enables developers to load data directly into database tables without using an external program like IntegrationServices. Although BULKINSERT does not allow the inclusion of any complex logic or transformations, it provides options related to formatting and tells us how the import is implemented. One usage limitation of BULKINSERT is that you can only import data into SQLServer.
The following example of inserting data gives us a better understanding of how to use the BULKINSERT command. First, let's create a table called Sales into which we will insert data from a text file.
CREATETABLE[dbo] .[Sales]
(
[SaleID] [int]
[Product] [varchar] (10) NULL
[SaleDate] [datetime] NULL
[SalePrice] [money] NULL
)
When we use the BULKINSERT command to insert data, do not start the trigger in the target table, because the trigger slows down the data import process.
Bulkinsert example
In the next example, we will create a trigger on the Sales table to print the number of records inserted into the table.
CREATETRIGGERtr_Sales
ONSales
FORINSERT
AS
BEGIN
PRINTCAST (@ @ ROWCOUNTASVARCHAR (5)) + 'rowsInserted.'
END
Here we select the text file as the source data file, and the values in the text file are separated by commas. The file contains 1000 records, and its fields are directly associated with the fields of the Sales table. Since the values in the text file are separated by commas, we only need to specify FIELDTERMINATOR.
Thank you for reading! This is the end of the article on "how to use bulkinsert". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.