This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10724|Reply: 0

[Tips] Import the TXT file into the SQL statement in SQL Server

[Copy link]
Posted on 2/4/2015 5:05:44 PM | | |
[mw_shl_code=sql,true] DROP TABLE tb;
CREATE TABLE tb(name1 NVARCHAR(255),pwd NVARCHAR(255));

bulk insert tb from 'H:\Thunder Download\G1mail.txt'
WITH
(
        FIELDTERMINATOR =':' ,-- column separator
        ROWTERMINATOR = '\n', --row separator
        FIRSTROW = 1 , -- Specifies the row number of the first row to load. The default value is the first line in the specified data file
        LASTROW = 4929076, -- Specifies the line number of the last line to load
  CHECK_CONSTRAINTS, --Specifies that all constraints on the target table or view must be checked during a bulk import operation
  DATAFILETYPE = 'widechar',
  KEEPIDENTITY
)


GO


select top 100 *from tb; [/mw_shl_code]




Previous:High Availability in SQL Server (1) ---- an overview of high availability
Next:Qihoo 360 spent $17 million to buy 360.com domain name, equivalent to 106 million personal currency
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com