我有两个.txt文件。第一个文件(out.txt)的数据如下:
empno,ename
'7369','SMITH'
'7499','ALLEN'
'7521','WARD'
'7566','JONES'
'7654','MARTIN'
'7698','BLAKE'
'7782','CLARK'
我的第二个文件(Output.txt)包含如下数据:
empno,ename,hiredate,comm
'7369','SMITH','1980-12-17',NULL
'7499','ALLEN','1981-02-20','300.00'
'7521','WARD','1981-02-22','500.00'
'7566','JONES','1981-04-02',NULL
'7654','MARTIN','1981-09-28','1400.00'
'7698','BLAKE','1981-05-01',NULL
'7782','CLARK','1981-06-09',NULL
现在当我为第一个文件执行以下语句时,我得到了我想要的输出:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\Data Migration;','SELECT * FROM out.txt'
但是当我为第二个文件执行相同的代码时,我收到一个错误:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\Data Migration;','SELECT * FROM Output.txt'
我得到的错误是:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an
error. The provider did not give any information about the error.
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT * FROM Output.txt" for execution
against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
我的理解是,因为我的第二个文件有一些NULL值,这将是错误的原因。那么在这种情况下,有人可以帮我处理NULL吗?
答案 0 :(得分:1)
您可以使用ISNULL选项并替换为您想要的值。