1/Set up data tables first
CREATE TABLE basicmsg
(
Recvtime FLOAT not NULL,--Receive time, no data with the same time
AA INT not NULL,--24-bit address code.
Flightid Varchar () NULL,-flight number
)
2/Set up stored procedures
Use Df17datapro
IF EXISTS (SELECT * from SYS.) Procedures WHERE object_id = object_id (N ' [dbo].[ Bulkdataproc]))
DROP PROC [DBO]. [Bulkdataproc]
GO
--Output NIC values in each range
CREATE PROCEDURE Bulkdataproc
As
SET NOCOUNT on
BULK INSERT basicmsg from ' d:\\writedatafile.txt '--location with filename//BasicMsg11
With
(
--KeepIdentity,
FieldTerminator = ', ',
Rowterminator = ' \ n '
)
GO
EXECute Bulkdataproc--1
3/writedatafile.txt File Content Format
43255,7867628,cca1519
4/Precautions
--Perform the above steps in order to insert the contents of the file into the database;
--Use the above method to make an error when there are self-increment columns in the data table; see the second article, "SQL SERVER uses BULK INSERT to BULK INSERT data from a TXT file into a table (2)"
SQL SERVER uses BULK INSERT to BULK INSERT data from a TXT file into a table (1)