Sunday, March 11, 2012
BULK INSERT from secured share
I am trying to use BULK INSERT to import data from a file that resides
on a shared drive. I've read many posts about this, but my situation
has a slight wrinkle (or two). The network people here have granted one
account that has access to this shared drive and I can map to that
drive using that user name and password:
NET USE X: \\PCName\Share password /user:username.
When run this command through a job I can then access the files through
DTS. Of course, for BULK INSERT it uses the SQL Server service account,
which is different from the SQL Server Agent service account, so it
can't access that drive (even as a UNC) because it has been mapped by a
different user. Am I correct so far?
I suspect that if I could use xp_cmdshell that I could map it with that
and the share would be available through BULK INSERT. I'm going to set
up a test on a local box to test this just for my own knowledge, but of
course on the production server xp_cmdshell is forbidden.
Possible solutions that I've come up with are:
1. Convince the network people to grant access to that drive to the SQL
Server service account (wish me LOTS of luck on that one
2. Convince the SQL Server guys that they should allow xp_cmdshell (ok,
that is impossible no matter how much luck you wish me)
3. Copy the files to the local box using a job (I'd like to avoid that
if possible)
Any other ideas?
Oh yeah, this is SQL Server 2000 on a Windows 2003 server. I don't
really have any access to the OS of the server and even my access to
the SQL side of things is pretty limited.
Thanks!
-Tom.You might be able to make use of OPENROWSET to read the text file,
instead of using DTS.|||Tracy McKibben wrote:
> You might be able to make use of OPENROWSET to read the text file,
> instead of using DTS.
Thanks, I'll look into that. Any idea on how I would set up the
connection string? I'm not familiar with doing a "connect as" through
an OLE DB provider for text files.
Thanks,
-Tom.|||Offhand, no, I'd have to look around for some examples - lots of them
on the web.
I don't think you'll need to do any sort of "connect as". You should
be able to specify the UNC path to the text file, and when you run the
code from an Agent job, it will run (and connect) under the context of
the SQL Agent user.
Bulk Insert from Mapped Network Drive
Hi,
I am trying to perform bulk insert using mapped network drive, but getting following error:
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file 'F:\Download\MVY.b45' could not be opened. Operating system error code 5(Access is denied.).
F is mapped network drive pointing to my SQL Database Server.
While searching, i got the following link but not able to relate with my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;238238
One exe is running on component server [CTom] and copying the data file to mapped drive (i.e. F:\), then bulk insert is trying to insert from that mapped drive.
Any idea/suggestion would be of great help
If file is a remote file (in your case a mapped network drive), specify the Universal Naming Convention (UNC) name.
|||You should as has been said use a UNC path, mapped drives are specific to a user profile and not the whole server. a UNC path resolves this.
In addition if you are fortunate enough to be running in a NT4 domain then you may encounter a problem if you are connecting from computer A to SQL on computer B which is trying to BULK insert from computer C. This is due to a tightening of security in SQL 2005 and the issue with 2 stage impersonation which can't be done in NT4.
|||Still, the original problem is permissions, though I agree that the best practice is to specify remote paths by UNC instead of relying on mapping drives.
To get rid of the access denied message, you must make sure that the account performing the bulk insert has the rights to read your file on the remote share. This account is the account that the SQL Server service is using - not the account of the user issuing the query.
=;o)
/Kenneth
That was the case with SQL 2000 but not the case with SQL 2005 if using a trusted connection. This is the section from BOL.
Security Account Delegation
If a SQL Server user is logged in using Windows authentication, the user can read only the files accessible to the user account, independent of the security profile of the SQL Server process. For more information, see Security Considerations for Using Transact-SQL to Bulk Import Data.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help
|||Though this only applies if Kerberos is used, if I remember correctly?
(ie it's not entirely enough to use SQL 2005, the windows environment also needs to support delegation)
But, do we know what platform the poster is on?
If he's on anything else than SQL 2005 and a windows environment supporting Kerberos, isn't it then the case that the account in question is the SQL Server service account that needs the remote permissions...
Until we know more details, it's hard to say where exactly the problem lies.
What we do know it that it's permissions related.
=;o)
/Kenneth
I guess we're back at square one then?
We don't know if the poster is on SQL Server 2005, or if his environment is able to use Kerberos for delegation. All we know so far is that he is getting an 'access denied' message. =:o/
/Kenneth
|||I am encountering the same issue...
I am running a BI query on my desktop to a SQL 2005 server trying to load a file from a 3rd server.
bulk insert OST_DataComm_Log_Data_Load
from '\\myserver\r-drive\DataComm\Logs\Site2Site.Log'
with
(
datafiletype = 'char',
rowterminator = '\n',
TABLOCK
)
My login account has all the rights it needs as does the Network login account that I am running the SQL Service under. I can browse to the file using either login.
I am using the UNC naming convention.
If I login to the SQL 2005 server as myself, they query runs correctly and loads the data. If i login to my workstation and use SQL Server Management Studio, the query fails with:
Msg 4861, Level 16, State 1, Line 7
Cannot bulk load because the file "\\myserver\r-drive\DataComm\Logs\Site2Site.Log" could not be opened. Operating system error code 5(Access is denied.).
|||This snippet is from BOL.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help.
It does seem similar to your problem.
/Kenneth
|||I too am experiencing an Access is Denied error when trying to bulk insert a file from a network path. As with previous posters, if I login to the server (Computer1) and execute the bulk insert command (using a query in Sql Server Management Studio):
BULK INSERT Tmp_Peptide_Import FROM '\\Computer3\LTQ\InputFile.txt'
the data successfully loads into the table. However, if I'm using my desktop machine (Computer2, running Windows XP SP2) connect to the server (Computer1, which is running Sql Server 2005 SP1 on Windows 2003 Server) and try to bulk insert the data from the third computer (Computer3), the bulk insert fails (using SSMS or Query Analyzer). I do not encounter this problem with Sql Server 2000 so it is definitely a result of tightening the security.
I've read the BOL entries that discuss delegation and authentication and I don't see what to change on the server. I'm not bulk inserting data from a remote Sql Server instance -- I'm bulk inserting data from a text file that happens to reside on a network share. If I copy the file to the server (Computer1), then I can bulk insert the data when connected from my desktop computer.
Note that another thread is present in the MSDN Forums on this issue, though the posts there were not helpful for me; see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=107193&SiteID=1
|||Your machines have to reside in an active directory domain or change your login to the sql server to be sql authentication|||All three machines are members of an active directory domain, the username running the Sql Server service is a domain user, and I'm connecting to the Sql Server as a domain user. You are correct that if I connect with a Sql Server login, then the Bulk Insert is successfull. Can you explain why the Bulk Insert works with a Sql Server login but not as a domain user? What was changed between Sql Server 2000 and Sql Server 2005? Or, is this a Windows 2003 Server issue? Any suggestions on configuration changes would be helpful. Note, too, that several people have experienced this problem and thus it would be helpful if the Sql Server development team could look into fixing this problem (or making it easier to update the permissions to fix this problem) in a future service pack for Sql Server 2005.
|||In SQL Server 2005, with Windows authentication the server will always impersonate the user's credentials. This means when you connect from say desktop1 to server1 accessing files on server2 you need to have security delegation setup. In your case, the security delegation should be setup for the service user account/port combination and registered. In older versions, once the user is authenticated in SQL Server the service credentials will be used to access external resources. This is still the case in SQL Server 2005 for users authenticated via SQL logins.|||One key to validating permissions for this (and getting rid of the "Anonymous Login" attempt in the security event log of the fileshare server) is to make sure you are using KERBEROS authentication. One easy way in SQL 2005 to do this is executing:select auth_scheme from sys.dm_exec_connections
where session_id=@.@.spid
It should say KERBEROS, and NOT NTLM, ... thats what worked for us anyway. :)
BULK INSERT from a file share would not work for us until we were using Kerberos authentication, as delegation does not work using NTLM.
Bulk Insert from Mapped Network Drive
Hi,
I am trying to perform bulk insert using mapped network drive, but getting following error:
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file 'F:\Download\MVY.b45' could not be opened. Operating system error code 5(Access is denied.).
F is mapped network drive pointing to my SQL Database Server.
While searching, i got the following link but not able to relate with my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;238238
One exe is running on component server [CTom] and copying the data file to mapped drive (i.e. F:\), then bulk insert is trying to insert from that mapped drive.
Any idea/suggestion would be of great help
If file is a remote file (in your case a mapped network drive), specify the Universal Naming Convention (UNC) name.
|||You should as has been said use a UNC path, mapped drives are specific to a user profile and not the whole server. a UNC path resolves this.
In addition if you are fortunate enough to be running in a NT4 domain then you may encounter a problem if you are connecting from computer A to SQL on computer B which is trying to BULK insert from computer C. This is due to a tightening of security in SQL 2005 and the issue with 2 stage impersonation which can't be done in NT4.
|||Still, the original problem is permissions, though I agree that the best practice is to specify remote paths by UNC instead of relying on mapping drives.
To get rid of the access denied message, you must make sure that the account performing the bulk insert has the rights to read your file on the remote share. This account is the account that the SQL Server service is using - not the account of the user issuing the query.
=;o)
/Kenneth
That was the case with SQL 2000 but not the case with SQL 2005 if using a trusted connection. This is the section from BOL.
Security Account Delegation
If a SQL Server user is logged in using Windows authentication, the user can read only the files accessible to the user account, independent of the security profile of the SQL Server process. For more information, see Security Considerations for Using Transact-SQL to Bulk Import Data.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help
|||Though this only applies if Kerberos is used, if I remember correctly?
(ie it's not entirely enough to use SQL 2005, the windows environment also needs to support delegation)
But, do we know what platform the poster is on?
If he's on anything else than SQL 2005 and a windows environment supporting Kerberos, isn't it then the case that the account in question is the SQL Server service account that needs the remote permissions...
Until we know more details, it's hard to say where exactly the problem lies.
What we do know it that it's permissions related.
=;o)
/Kenneth
I guess we're back at square one then?
We don't know if the poster is on SQL Server 2005, or if his environment is able to use Kerberos for delegation. All we know so far is that he is getting an 'access denied' message. =:o/
/Kenneth
|||I am encountering the same issue...
I am running a BI query on my desktop to a SQL 2005 server trying to load a file from a 3rd server.
bulk insert OST_DataComm_Log_Data_Load
from '\\myserver\r-drive\DataComm\Logs\Site2Site.Log'
with
(
datafiletype = 'char',
rowterminator = '\n',
TABLOCK
)
My login account has all the rights it needs as does the Network login account that I am running the SQL Service under. I can browse to the file using either login.
I am using the UNC naming convention.
If I login to the SQL 2005 server as myself, they query runs correctly and loads the data. If i login to my workstation and use SQL Server Management Studio, the query fails with:
Msg 4861, Level 16, State 1, Line 7
Cannot bulk load because the file "\\myserver\r-drive\DataComm\Logs\Site2Site.Log" could not be opened. Operating system error code 5(Access is denied.).
|||This snippet is from BOL.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help.
It does seem similar to your problem.
/Kenneth
|||I too am experiencing an Access is Denied error when trying to bulk insert a file from a network path. As with previous posters, if I login to the server (Computer1) and execute the bulk insert command (using a query in Sql Server Management Studio):
BULK INSERT Tmp_Peptide_Import FROM '\\Computer3\LTQ\InputFile.txt'
the data successfully loads into the table. However, if I'm using my desktop machine (Computer2, running Windows XP SP2) connect to the server (Computer1, which is running Sql Server 2005 SP1 on Windows 2003 Server) and try to bulk insert the data from the third computer (Computer3), the bulk insert fails (using SSMS or Query Analyzer). I do not encounter this problem with Sql Server 2000 so it is definitely a result of tightening the security.
I've read the BOL entries that discuss delegation and authentication and I don't see what to change on the server. I'm not bulk inserting data from a remote Sql Server instance -- I'm bulk inserting data from a text file that happens to reside on a network share. If I copy the file to the server (Computer1), then I can bulk insert the data when connected from my desktop computer.
Note that another thread is present in the MSDN Forums on this issue, though the posts there were not helpful for me; see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=107193&SiteID=1
|||Your machines have to reside in an active directory domain or change your login to the sql server to be sql authentication|||All three machines are members of an active directory domain, the username running the Sql Server service is a domain user, and I'm connecting to the Sql Server as a domain user. You are correct that if I connect with a Sql Server login, then the Bulk Insert is successfull. Can you explain why the Bulk Insert works with a Sql Server login but not as a domain user? What was changed between Sql Server 2000 and Sql Server 2005? Or, is this a Windows 2003 Server issue? Any suggestions on configuration changes would be helpful. Note, too, that several people have experienced this problem and thus it would be helpful if the Sql Server development team could look into fixing this problem (or making it easier to update the permissions to fix this problem) in a future service pack for Sql Server 2005.
|||In SQL Server 2005, with Windows authentication the server will always impersonate the user's credentials. This means when you connect from say desktop1 to server1 accessing files on server2 you need to have security delegation setup. In your case, the security delegation should be setup for the service user account/port combination and registered. In older versions, once the user is authenticated in SQL Server the service credentials will be used to access external resources. This is still the case in SQL Server 2005 for users authenticated via SQL logins.|||One key to validating permissions for this (and getting rid of the "Anonymous Login" attempt in the security event log of the fileshare server) is to make sure you are using KERBEROS authentication. One easy way in SQL 2005 to do this is executing:select auth_scheme from sys.dm_exec_connections
where session_id=@.@.spid
It should say KERBEROS, and NOT NTLM, ... thats what worked for us anyway. :)
BULK INSERT from a file share would not work for us until we were using Kerberos authentication, as delegation does not work using NTLM.
Bulk Insert from Mapped Network Drive
Hi,
I am trying to perform bulk insert using mapped network drive, but getting following error:
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file 'F:\Download\MVY.b45' could not be opened. Operating system error code 5(Access is denied.).
F is mapped network drive pointing to my SQL Database Server.
While searching, i got the following link but not able to relate with my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;238238
One exe is running on component server [CTom] and copying the data file to mapped drive (i.e. F:\), then bulk insert is trying to insert from that mapped drive.
Any idea/suggestion would be of great help
If file is a remote file (in your case a mapped network drive), specify the Universal Naming Convention (UNC) name.
|||You should as has been said use a UNC path, mapped drives are specific to a user profile and not the whole server. a UNC path resolves this.
In addition if you are fortunate enough to be running in a NT4 domain then you may encounter a problem if you are connecting from computer A to SQL on computer B which is trying to BULK insert from computer C. This is due to a tightening of security in SQL 2005 and the issue with 2 stage impersonation which can't be done in NT4.
|||Still, the original problem is permissions, though I agree that the best practice is to specify remote paths by UNC instead of relying on mapping drives.
To get rid of the access denied message, you must make sure that the account performing the bulk insert has the rights to read your file on the remote share. This account is the account that the SQL Server service is using - not the account of the user issuing the query.
=;o)
/Kenneth
That was the case with SQL 2000 but not the case with SQL 2005 if using a trusted connection. This is the section from BOL.
Security Account Delegation
If a SQL Server user is logged in using Windows authentication, the user can read only the files accessible to the user account, independent of the security profile of the SQL Server process. For more information, see Security Considerations for Using Transact-SQL to Bulk Import Data.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help
|||Though this only applies if Kerberos is used, if I remember correctly?
(ie it's not entirely enough to use SQL 2005, the windows environment also needs to support delegation)
But, do we know what platform the poster is on?
If he's on anything else than SQL 2005 and a windows environment supporting Kerberos, isn't it then the case that the account in question is the SQL Server service account that needs the remote permissions...
Until we know more details, it's hard to say where exactly the problem lies.
What we do know it that it's permissions related.
=;o)
/Kenneth
I guess we're back at square one then?
We don't know if the poster is on SQL Server 2005, or if his environment is able to use Kerberos for delegation. All we know so far is that he is getting an 'access denied' message. =:o/
/Kenneth
|||I am encountering the same issue...
I am running a BI query on my desktop to a SQL 2005 server trying to load a file from a 3rd server.
bulk insert OST_DataComm_Log_Data_Load
from '\\myserver\r-drive\DataComm\Logs\Site2Site.Log'
with
(
datafiletype = 'char',
rowterminator = '\n',
TABLOCK
)
My login account has all the rights it needs as does the Network login account that I am running the SQL Service under. I can browse to the file using either login.
I am using the UNC naming convention.
If I login to the SQL 2005 server as myself, they query runs correctly and loads the data. If i login to my workstation and use SQL Server Management Studio, the query fails with:
Msg 4861, Level 16, State 1, Line 7
Cannot bulk load because the file "\\myserver\r-drive\DataComm\Logs\Site2Site.Log" could not be opened. Operating system error code 5(Access is denied.).
|||This snippet is from BOL.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help.
It does seem similar to your problem.
/Kenneth
|||I too am experiencing an Access is Denied error when trying to bulk insert a file from a network path. As with previous posters, if I login to the server (Computer1) and execute the bulk insert command (using a query in Sql Server Management Studio):
BULK INSERT Tmp_Peptide_Import FROM '\\Computer3\LTQ\InputFile.txt'
the data successfully loads into the table. However, if I'm using my desktop machine (Computer2, running Windows XP SP2) connect to the server (Computer1, which is running Sql Server 2005 SP1 on Windows 2003 Server) and try to bulk insert the data from the third computer (Computer3), the bulk insert fails (using SSMS or Query Analyzer). I do not encounter this problem with Sql Server 2000 so it is definitely a result of tightening the security.
I've read the BOL entries that discuss delegation and authentication and I don't see what to change on the server. I'm not bulk inserting data from a remote Sql Server instance -- I'm bulk inserting data from a text file that happens to reside on a network share. If I copy the file to the server (Computer1), then I can bulk insert the data when connected from my desktop computer.
Note that another thread is present in the MSDN Forums on this issue, though the posts there were not helpful for me; see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=107193&SiteID=1
|||Your machines have to reside in an active directory domain or change your login to the sql server to be sql authentication|||All three machines are members of an active directory domain, the username running the Sql Server service is a domain user, and I'm connecting to the Sql Server as a domain user. You are correct that if I connect with a Sql Server login, then the Bulk Insert is successfull. Can you explain why the Bulk Insert works with a Sql Server login but not as a domain user? What was changed between Sql Server 2000 and Sql Server 2005? Or, is this a Windows 2003 Server issue? Any suggestions on configuration changes would be helpful. Note, too, that several people have experienced this problem and thus it would be helpful if the Sql Server development team could look into fixing this problem (or making it easier to update the permissions to fix this problem) in a future service pack for Sql Server 2005.
|||In SQL Server 2005, with Windows authentication the server will always impersonate the user's credentials. This means when you connect from say desktop1 to server1 accessing files on server2 you need to have security delegation setup. In your case, the security delegation should be setup for the service user account/port combination and registered. In older versions, once the user is authenticated in SQL Server the service credentials will be used to access external resources. This is still the case in SQL Server 2005 for users authenticated via SQL logins.|||One key to validating permissions for this (and getting rid of the "Anonymous Login" attempt in the security event log of the fileshare server) is to make sure you are using KERBEROS authentication. One easy way in SQL 2005 to do this is executing:select auth_scheme from sys.dm_exec_connections
where session_id=@.@.spid
It should say KERBEROS, and NOT NTLM, ... thats what worked for us anyway. :)
BULK INSERT from a file share would not work for us until we were using Kerberos authentication, as delegation does not work using NTLM.
Bulk Insert from Mapped Network Drive
Hi,
I am trying to perform bulk insert using mapped network drive, but getting following error:
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file 'F:\Download\MVY.b45' could not be opened. Operating system error code 5(Access is denied.).
F is mapped network drive pointing to my SQL Database Server.
While searching, i got the following link but not able to relate with my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;238238
One exe is running on component server [CTom] and copying the data file to mapped drive (i.e. F:\), then bulk insert is trying to insert from that mapped drive.
Any idea/suggestion would be of great help
If file is a remote file (in your case a mapped network drive), specify the Universal Naming Convention (UNC) name.
|||You should as has been said use a UNC path, mapped drives are specific to a user profile and not the whole server. a UNC path resolves this.
In addition if you are fortunate enough to be running in a NT4 domain then you may encounter a problem if you are connecting from computer A to SQL on computer B which is trying to BULK insert from computer C. This is due to a tightening of security in SQL 2005 and the issue with 2 stage impersonation which can't be done in NT4.
|||Still, the original problem is permissions, though I agree that the best practice is to specify remote paths by UNC instead of relying on mapping drives.
To get rid of the access denied message, you must make sure that the account performing the bulk insert has the rights to read your file on the remote share. This account is the account that the SQL Server service is using - not the account of the user issuing the query.
=;o)
/Kenneth
That was the case with SQL 2000 but not the case with SQL 2005 if using a trusted connection. This is the section from BOL.
Security Account Delegation
If a SQL Server user is logged in using Windows authentication, the user can read only the files accessible to the user account, independent of the security profile of the SQL Server process. For more information, see Security Considerations for Using Transact-SQL to Bulk Import Data.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help
|||Though this only applies if Kerberos is used, if I remember correctly?
(ie it's not entirely enough to use SQL 2005, the windows environment also needs to support delegation)
But, do we know what platform the poster is on?
If he's on anything else than SQL 2005 and a windows environment supporting Kerberos, isn't it then the case that the account in question is the SQL Server service account that needs the remote permissions...
Until we know more details, it's hard to say where exactly the problem lies.
What we do know it that it's permissions related.
=;o)
/Kenneth
I guess we're back at square one then?
We don't know if the poster is on SQL Server 2005, or if his environment is able to use Kerberos for delegation. All we know so far is that he is getting an 'access denied' message. =:o/
/Kenneth
|||I am encountering the same issue...
I am running a BI query on my desktop to a SQL 2005 server trying to load a file from a 3rd server.
bulk insert OST_DataComm_Log_Data_Load
from '\\myserver\r-drive\DataComm\Logs\Site2Site.Log'
with
(
datafiletype = 'char',
rowterminator = '\n',
TABLOCK
)
My login account has all the rights it needs as does the Network login account that I am running the SQL Service under. I can browse to the file using either login.
I am using the UNC naming convention.
If I login to the SQL 2005 server as myself, they query runs correctly and loads the data. If i login to my workstation and use SQL Server Management Studio, the query fails with:
Msg 4861, Level 16, State 1, Line 7
Cannot bulk load because the file "\\myserver\r-drive\DataComm\Logs\Site2Site.Log" could not be opened. Operating system error code 5(Access is denied.).
|||This snippet is from BOL.
When executing the BULK INSERT statement using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.
To resolve this use SQL Server Authentication and specify a SQL Server login, which uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about enabling a user account to be trusted for delegation, see Windows Help.
It does seem similar to your problem.
/Kenneth
|||I too am experiencing an Access is Denied error when trying to bulk insert a file from a network path. As with previous posters, if I login to the server (Computer1) and execute the bulk insert command (using a query in Sql Server Management Studio):
BULK INSERT Tmp_Peptide_Import FROM '\\Computer3\LTQ\InputFile.txt'
the data successfully loads into the table. However, if I'm using my desktop machine (Computer2, running Windows XP SP2) connect to the server (Computer1, which is running Sql Server 2005 SP1 on Windows 2003 Server) and try to bulk insert the data from the third computer (Computer3), the bulk insert fails (using SSMS or Query Analyzer). I do not encounter this problem with Sql Server 2000 so it is definitely a result of tightening the security.
I've read the BOL entries that discuss delegation and authentication and I don't see what to change on the server. I'm not bulk inserting data from a remote Sql Server instance -- I'm bulk inserting data from a text file that happens to reside on a network share. If I copy the file to the server (Computer1), then I can bulk insert the data when connected from my desktop computer.
Note that another thread is present in the MSDN Forums on this issue, though the posts there were not helpful for me; see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=107193&SiteID=1
|||Your machines have to reside in an active directory domain or change your login to the sql server to be sql authentication|||All three machines are members of an active directory domain, the username running the Sql Server service is a domain user, and I'm connecting to the Sql Server as a domain user. You are correct that if I connect with a Sql Server login, then the Bulk Insert is successfull. Can you explain why the Bulk Insert works with a Sql Server login but not as a domain user? What was changed between Sql Server 2000 and Sql Server 2005? Or, is this a Windows 2003 Server issue? Any suggestions on configuration changes would be helpful. Note, too, that several people have experienced this problem and thus it would be helpful if the Sql Server development team could look into fixing this problem (or making it easier to update the permissions to fix this problem) in a future service pack for Sql Server 2005.
|||In SQL Server 2005, with Windows authentication the server will always impersonate the user's credentials. This means when you connect from say desktop1 to server1 accessing files on server2 you need to have security delegation setup. In your case, the security delegation should be setup for the service user account/port combination and registered. In older versions, once the user is authenticated in SQL Server the service credentials will be used to access external resources. This is still the case in SQL Server 2005 for users authenticated via SQL logins.|||One key to validating permissions for this (and getting rid of the "Anonymous Login" attempt in the security event log of the fileshare server) is to make sure you are using KERBEROS authentication. One easy way in SQL 2005 to do this is executing:select auth_scheme from sys.dm_exec_connections
where session_id=@.@.spid
It should say KERBEROS, and NOT NTLM, ... thats what worked for us anyway. :)
BULK INSERT from a file share would not work for us until we were using Kerberos authentication, as delegation does not work using NTLM.
BULK INSERT from a mapped drive
I'm trying to BULK INSERT some data from a simple text file, residing on a
mapped drive (F:\)
Well, I know, it's better to use UNC-Paths, but it was "programmed" in that
manner some years ago. (Some dozens of stored procs which I don't want to
change)
This problem persists since we upgraded from NT/2000 to Server2003 (still
using SQL 2000):
while trying to bulk insert, I get an error, that the file can't be
found/accessed. (Path is correct)
MSDTC is configured running as a Domain-Account, and accessing the network
(COM-Configuration)
MSSQLSERVER-service is also configured as a Domain-Account.
Could this be a setting in Server2003 which I didn't found yet ?
Any help would be appreciated
Many thanks & regards,
MarcFist thing to try would be to log in as the SQL Server service account as se
e if the mapping exists for that
account.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Marc" <newsgroups@.ris-nospam-web.net> wrote in message news:409143a0$0$713$5402220f@.news.su
nrise.ch...
> Hi
> I'm trying to BULK INSERT some data from a simple text file, residing on a
> mapped drive (F:\)
> Well, I know, it's better to use UNC-Paths, but it was "programmed" in tha
t
> manner some years ago. (Some dozens of stored procs which I don't want to
> change)
> This problem persists since we upgraded from NT/2000 to Server2003 (still
> using SQL 2000):
> while trying to bulk insert, I get an error, that the file can't be
> found/accessed. (Path is correct)
> MSDTC is configured running as a Domain-Account, and accessing the network
> (COM-Configuration)
> MSSQLSERVER-service is also configured as a Domain-Account.
> Could this be a setting in Server2003 which I didn't found yet ?
> Any help would be appreciated
> Many thanks & regards,
> Marc
>|||Tibor,
Yes, the mapped drive is visible & accessible by the Account.
Marc
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> schrieb
im Newsbeitrag news:O0QxpUhLEHA.1388@.TK2MSFTNGP09.phx.gbl...
> Fist thing to try would be to log in as the SQL Server service account as
see if the mapping exists for that
> account.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Marc" <newsgroups@.ris-nospam-web.net> wrote in message
news:409143a0$0$713$5402220f@.news.sunrise.ch...
a[vbcol=seagreen]
that[vbcol=seagreen]
to[vbcol=seagreen]
(still[vbcol=seagreen]
network[vbcol=seagreen]
>|||Hmm, then I can only assume that there's some new stuff in W2K3 that I haven
't heard about before. Perhaps
post this to a Windows forum as a general question ("service accessing share
through mapped drive")?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Marc" <newsgroups@.ris-nospam-web.net> wrote in message news:40914a26$0$704$5402220f@.news.su
nrise.ch...
> Tibor,
> Yes, the mapped drive is visible & accessible by the Account.
> Marc
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> schrieb
> im Newsbeitrag news:O0QxpUhLEHA.1388@.TK2MSFTNGP09.phx.gbl...
> see if the mapping exists for that
> news:409143a0$0$713$5402220f@.news.sunrise.ch...
> a
> that
> to
> (still
> network
>|||Tibor,
Thank's for your help...
Marc
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> schrieb
im Newsbeitrag news:uoy$WViLEHA.1388@.TK2MSFTNGP09.phx.gbl...
> Hmm, then I can only assume that there's some new stuff in W2K3 that I
haven't heard about before. Perhaps
> post this to a Windows forum as a general question ("service accessing
share through mapped drive")?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "Marc" <newsgroups@.ris-nospam-web.net> wrote in message
news:40914a26$0$704$5402220f@.news.sunrise.ch...
schrieb[vbcol=seagreen]
as[vbcol=seagreen]
residing on[vbcol=seagreen]
in[vbcol=seagreen]
want[vbcol=seagreen]
>
Friday, February 24, 2012
Bulk Insert
an error that access is denied. However, if I run the
file name from the start menu it will open the file just
fine or if I run the bulk insert from the local drive of
the server it runs fine.
The directory on the network is everyone full control.
Any idea's?Check the account and permissions for the SQL Server
service. It needs to be a domain account with the
appropriate access. Sounds like you could be running the
service under LocalSystem which does not have access to
network resources.
-Sue
On Tue, 6 Apr 2004 12:23:32 -0700, "Eric"
<anonymous@.discussions.microsoft.com> wrote:
>I cannot bulk insert a file from a network drive. Getting
>an error that access is denied. However, if I run the
>file name from the start menu it will open the file just
>fine or if I run the bulk insert from the local drive of
>the server it runs fine.
>The directory on the network is everyone full control.
>Any idea's?|||Hi,
The Service startup account for MSSQL server service should have privilage
to access the file in the destination machine.
To do this
1. Start MSSQL server service using a Domain OS User
2. That user should have access to the destination machine share as well as
the file to load.
3. Incase if you change the Startup service account you need to restart the
service to make the changes come into effect.
4. After this try login to Query Analyzer and execute the Bulk insert again
by providing the UNC path.
Thanks
Hari
MCDBA
"Eric" <anonymous@.discussions.microsoft.com> wrote in message
news:1644601c41c0c$a60d20c0$a601280a@.phx
.gbl...
> I cannot bulk insert a file from a network drive. Getting
> an error that access is denied. However, if I run the
> file name from the start menu it will open the file just
> fine or if I run the bulk insert from the local drive of
> the server it runs fine.
> The directory on the network is everyone full control.
> Any idea's?