我想導出到使用BCP這樣的CSV文件:SQL Server 2008中BCP出口拋出:NativeError = 945,數據庫無法打開,由於無法訪問文件或內存不足
DECLARE @SQL AS VARCHAR(1000)
DECLARE @CMD AS VARCHAR(8000)
SET @SQL='SELECT * from Pondor.dbo.tblLD'
SET @CMD = 'bcp "' + @SQL + '" QUERYOUT "' + @FILE + '" -c -t "," -U"UserA" -P"Password"
exec master..xp_cmdshell @cmd
這不起作用並拋出以下錯誤:
SQLState = 37000, NativeError = 945
Database 'Pondor' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
做一個SELECT * from Pondor.dbo.tblLD
工作並返回行。有關BCP命令有什麼問題的任何想法?
當發出該命令的用戶是sysadmin組的成員時,將在運行SQL Server服務的安全上下文中執行xp_cmdshell。當用戶不是sysadmin組的成員時,xp_cmdshell將模擬使用xp_sqlagent_proxy_account指定的SQL Server代理代理帳戶。 很可能你的用戶沒有權限訪問你的文件。 –