Skip over Bulk Insert when the file does not exist - sqlserver
来源:互联网 发布:linux开机硬件启动顺序 编辑:程序博客网 时间:2024/06/11 01:00
Problem/symptom:
In SQL Server Management Studio 2008, the file does not exist then I
get the error "Cannot bulk load. The file "C:/scratch.txt" does not
exist."
when I run the script , the Bulk Insert is
totally ignored because of error: "the file doesn't exist. "
Probably Answer:
1. The problem is that SQL is running under a local account. This doesn't have
access to the remote fileshare. You would need to run under a domain user
account.
2. Depedning on how this is run, either your NT login, or the NT login SQL
Server uses, or the login SQL Agent uses ( if a scheduled TSQL task) must
have the appropriate permissions....
3. SqlServer is running on an admin account of the local box only. The box
has been joined to the domain but the user that sql runs under doesn't exist
in the domain. I would prefer not to have sql run under a domain account if
there is a way to impersonate a user of the domain during the script but if
SQL needs to run under a domain user then I guess that's what needs to be
done. Do you have any further suggestions?
4.Please be aware that this will fail if you service security context is
LocalSystem or a local machine account (assuming the UNC name points to a
remote server).
5.Does the service account that SQL Server runs under have permissions to the networked drive?
If you are running SQL Server under the local system account, it will have no access to anything off the box it is running on.
6.xp_fileexists won't work with networked drive letters, but it will work if you use the UNC share name.
7. IP address does not belong here.
Use proper UNC notation.
8.
IP address will work but you must reference a share on the remote server and the SQL Server service account must have access to that share. Each partitions has a default Administrative share,which is referenced with the partition letter followed by a dollar sign ( $ )
Example:
EXEC master..xp_fileexist '//10.218.4.71/C$/boot.ini'
Results are:
File Exists File is a Directory Parent Directory Exists
----------- ------------------- -----------------------
1 0 1
Please be aware that if the SQL Server service account does not have access to the share, then "xp_fileexist" will report that the file does not exist and the return code indicates success. "xp_cmdshell" however,does return a non-zero return code.
declare @sprc int
EXEC @sprc = master..xp_cmdshell 'dir //10.218.32.159/c$/boot.ini'
select @sprc as CmdShell_ReturnCode
output
--------------------------------------------------
Logon failure: unknown user name or bad password.
NULL
CmdShell_ReturnCode
-------------------
1
SQL = Scarcely Qualifies as a Language
Source:
http://www.keyongtech.com/2218256-help-with-xp_fileexist
http://www.sqlservercentral.com/Forums/Topic566704-338-1.aspx
- Skip over Bulk Insert when the file does not exist - sqlserver
- The file does not exist anymore
- Could not open the editor: The file does not exist.
- The file does not exist for the external tool
- Parser Error Message: The file '/MasterPage.master' does not exist.
- 【C# 】Parser Error Message: The file 'XXXXXX' does not exist
- This File Does Not Exist At The Requested Revision
- Android Studio The APK file does not exist on disk
- The APK file **** does not exist on disk
- Android Studio The APK file does not exist on disk
- The APK file does not exist on disk
- EmptyThrowable: The APK file does not exist on disk.
- The APK file does not exist on disk
- The APK file does not exist on disk
- [iOS]File does not exist
- The connection does not exist.
- The user specified as a definer ('root'@'') does not exist when
- User settings file does not exist
- test
- Windows消息处理机制(转li_guotao好文章)
- C#反射。。了解
- 【转】配置Visual Studio调试FrameWork源码
- one's complement sum
- Skip over Bulk Insert when the file does not exist - sqlserver
- Aqua DataStudio 注册机1.1.6版(支持ads 8.0.13|12|9|8|7 )
- 程序拨打电话函数汇总
- 强浩文档-新概念的背法
- 通过RIL获得呼入/呼出电话的号码
- 【练手】任意连续整数之间的的乘积
- 顺其自然不容易啊
- 开始学
- CSS 实现背景图片自适应td大小