BULK INSERT table FROM 'c:\file.txt'
我得到
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "c:\file.txt" could not be opened. Operating system error code 32(The process cannot access the file because it is being used by another process.).
錯誤,因爲該文件是由另一個進程打開日誌文件。
但是與C#我可以打開該文件System.IO.FileShare.ReadWrite
爲:
using (System.IO.FileStream fileStream = new System.IO.FileStream("c:\\file.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
{
using (System.IO.StreamReader streamReader = new System.IO.StreamReader(fileStream))
{
file = streamReader.ReadToEnd();
}
}
有沒有辦法讓SQL服務器(BULK INSERT或任何其他)內的讀寫共享功能?
感謝
不錯的解決方法 – 2013-03-06 23:32:02
+1。擊敗我! – 2013-03-06 23:32:51