带格式的文本串,如何使用BCP导入数据库, 单引号‘’如何处理

类别:数据库 点击:0 评论:0 推荐:

我使用格式如下:

EXEC master..xp_cmdshell 'bcp SERP.dbo.IOData in C:\200410\07.txt -fc:\200410\iodata.txt -Usa -P'
系统报错:
Error = [Microsoft][ODBC SQL Server Driver]对于造型说明无效的字符值

文本格式为:
'02','1','20041007','000330','0812','A0001'
'02','5','20041007','003105','0812','A0002'
'01','6','20041007','003415','0447','A0002'
'01','6','20041007','003417','0239','A0002'
'01','6','20041007','004422','0799','A0002'
'02','1','20041007','011803','0005','A0001'

格式文件为:
8.0
6
1       SQLCHAR       1       2       ","     1     Door        ""
2       SQLCHAR       1       1       ","     2     Control     ""
3       SQLCHAR       1       8       ","     3     IODate      Chinese_PRC_CI_AS
4       SQLCHAR       1       6       ","     4     IOTime      Chinese_PRC_CI_AS
5       SQLCHAR       1       4       ","     5     CardNo      Chinese_PRC_CI_AS
6       SQLCHAR       1       5       "\r\n"    6     Flag        Chinese_PRC_CI_AS

数据库表格式为:
Door int
Control int
IODate Char 8
IOTime char 6
CardNo  char 4
flag char 5

本文地址:http://com.8s8s.com/it/it20162.htm