简体   繁体   中英

C:\Temp\PetSales.fmt could not be read. Operating system error code (null)

I am trying to import some data from a text file into a table in my database. However i get the following error: "C:\\Temp\\PetSales.fmt could not be read. Operating system error code (null)" What does this mean? Im wondering is it because i have put 0 for the destination columns which i dont want to import into my table (Column 3, 5, 6)?

  • Sales = My table
  • PetDatabase = The name of my database holding queries, tables, etc.
  • P1 = Is my text file with 14 columns
  • PetSales.FMT = Is my notepad file which i have changed the extension to FMT.

My following SQL statement:

BULK INSERT Sales
FROM 'C:\Temp\P1.txt' 
WITH 
(FORMATFILE = 'C:\Temp\PetSales.FMT')

Format file:

10.0
14
1       SQLDATETIME   0       0       ","     3     Date   SQL_Latin1_General_CP1_CI_AS
2       SQLDATETIME   0       0       ","     4     Time   SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR       0       0       ","     0     Pet    SQL_Latin1_General_CP1_CI_AS
4       SQLCHAR       0       0       ","     1     order  SQL_Latin1_General_CP1_CI_AS
5       SQLCHAR       0       0       ","     0     Pet    SQL_Latin1_General_CP1_CI_AS
6       SQLCHAR       0       0       ","     0     Pet    SQL_Latin1_General_CP1_CI_AS
7       SQLCHAR       0       0       ","     5     Desc   SQL_Latin1_General_CP1_CI_AS
8       SQLCHAR       0       0       ","     6     Tele   SQL_Latin1_General_CP1_CI_AS
9       SQLCHAR       0       0       ","     7     Mob    SQL_Latin1_General_CP1_CI_AS
10      SQLCHAR       0       0       ","     8  Customer  SQL_Latin1_General_CP1_CI_AS
11      SQLCHAR       0       0       ","     9  Address 1 SQL_Latin1_General_CP1_CI_AS
12      SQLCHAR       0       0       ","     10 Address 2 SQL_Latin1_General_CP1_CI_AS
13      SQLCHAR       0       0       ","     11 Address 3 SQL_Latin1_General_CP1_CI_AS
14      SQLCHAR       0       0    "\r\n"   12   Address 4 SQL_Latin1_General_CP1_CI_AS

在行的末尾添加一个返回

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM