Straight to the point, directly with the example introduction:
Copy Code code as follows:
CREATE TABLE [dbo]. [Course] (
[ID] [int] NULL,
[Name] [nvarchar] (m) NULL,
[Coursetype] [nvarchar] (m) NULL,
[Course] [Float] Null
)
Import data:
Save the following data as a text file or SQL file
2, Li Gang, Chinese, 89;3, Li Gang, maths, 79;3, Li Gang, English, 69;4, Li Gang, chemistry, 89
Import statement:
Copy Code code as follows:
BULK INSERT Dbo.course
From ' D:\course.txt '
With
(
FieldTerminator = ', ',
Rowterminator = '; '
)
For examples of BULK inserts, see:
-
BULK INSERT (Transact-SQL)
-
Bulk Import and export XML document example
-
to copy data between different collations
-
Preserve identity values when bulk import data
-
Preserve Null values or use default values during Bulk import
-
Specify field terminator and line terminator
-
Bulk-Import data using a format file
-
Import or export data using character formatting
-
Import or export data using native format
-
Import or export data using Unicode character format
-
Import or export data using Unicode native format
-
Skip table columns using a format file
-
Use a format file to map table columns to data file fields