0
我有兩個.txt文件。第一個文件(out.txt)有如下數據:如何在SQL SERVER 2012中使用OPENROWSET處理NULL值?
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嗎?