SQL BULK COPY ERROR (“Operating system error code 5(Access is denied.)”)

Published Jan 15 2019 01:17 PM 11.9K Views
First published on MSDN on Oct 29, 2010


While there are various forms of bulk copy this blog specifically deals with copying data from a file into SQL Server. It deals about the specific error “Operating system error code 5(Access is denied.)” which might crop up under certain circumstances when doing a bulk copy. For a while now I worked with a lot of DBAs and Developers bewildered with the problem and most of them complaining about the lack of good documentation about it and hours spent diagnosing in the wrong direction. If you are looking for details about bulk copy visit http://msdn.microsoft.com/en-us/library/ms130809(SQL.90).aspx




You run the following query







BEGIN




BULK INSERT ENVPOT_R




FROM '\\advdev64\BulkTest\test_bulk_insert.txt'




WITH (  FIELDTERMINATOR = ';',   ROWTERMINATOR = '\n')




END




And end up getting the following error










Msg 4861, Level 16, State 1, Line 1




Cannot bulk load because the file





" \\advdev64\BulkTest\test_bulk_insert.txt " could not be opened.





Operating system error code 5(Access is denied.).






The usual troubleshooting that DBAs do is to chase the “Access Denied” error from a file/folder access perspective. Some of them are as follows.





a)      Added “full” access to “everyone” (just temporary to test this) on the BulkTest folder and still getting the same error.





b)      Added “full” access to the SQL server service account on the BulkTest folder and still get the same error.





c)       The user is made a member of the bulkadmin fixed server role.









Many DBAs come with prior experience on SQL Server 2000 where the following was true.





Once a user was authenticated, access to external files was based on the security profile of the SQL Server process. When the SQL Server process had read access to a file, for a user that did not have access to the file but was a member of the bulkadmin fixed server role, the user could import the file by using BULK INSERT and access the contents of the file.





But that had a security issue and the way SQL Server 2005 and later versions handle access to external files is different.





The following are the salient points you need to keep in consideration and are also mentioned in detail here http://msdn.microsoft.com/en-us/library/ms175915(SQL.90).aspx





a)      The data file must be shared between the two computers





b)      To specify a shared data file, use its universal naming convention (UNC) name, which takes the general form of \\ Servername \ Sharename \ ... .





c)       The user account that is used by SQL Server must have been granted the permissions that are required for reading the file on the remote disk.





But there is another important consideration that needs to be taken care of when we have a setting as below and Windows authentication is being used.










Client application from client machine à SQL Server (SQL service account impersonating client account) \\File Server (impersonated client credentials)





a)      We need to have CIFs SPN for the file server.





Whenever a computer is joined to a domain, it is assigned 2 SPN's by default: HOST/netbiosName, and HOST/FQDN.com. netbiosName being the machine name of the computer being joined to the domain, and FQDN.com being the fully qualified machine name. These two SPN's use the generic "HOST" service type which includes all the various services that *come*be default with Windows. Therefore, if we connect to http://machineName or http://machineName.company.com , we will already have SPN's set that will handle Kerberos when using those names. When trying to connect to \\machineName\SomeShareName we would be all set for Kerberos (UNC's need a "CIFS" SPN which is included under "HOST" also).





Complete list of the different service types included in HOST of can be found in this technet article.



b)      Configuring Kerberos delegation on the SQL Server box.





The requirements are as follows.






i)    A domain user running the query from management studio must not have the Account is sensitive and cannot be delegated selected option.











ii) SPNs must be registered for the SQL Server service if the service account is a domain account.



iii)  The client must be connecting to the SQL using TCP. http://support.microsoft.com/default.aspx?scid=kb;EN-US;811889










The service’s SPN must be registered by a domain administrator if the service account is a domain user account. If the service account uses the computer’s account, then the process can register by itself or the local administrator can register it by using Setspn.







At a command prompt, type:





setspn –L Account  domain\sqlServiceAccount







These two SPNs for SQL service account must come up for delegation to properly function:





•One for MSSQLSvc/Host:1433, where Host is the name of the host computer.





•One for MSSQLSvc/FQDN:1433 where FQDN is the fully qualified domain name of the computer running SQL Server .


The port number at the end may vary depending on the actual port the SQL Server is listening on. For the sake of brevity I have assumed the default port 1433.







If there are no MSSQLSvc SPNs listed or there is an SPN missing, then we need to add the appropriate SPN using the setspn –A command for delegation to work properly.









At a command prompt, type:





setspn -A MSSQLSvc/< Host >:<Port> <SQL_Service_Account>





setspn -A MSSQLSvc/<FQDN>:<Port> <SQL_Service_Account>



A sample is as below





setspn -A MSSQLSvc/MySQLServer:1433 domain\sqlServiceAccount





setspn -A MSSQLSvc/MySQLServer.MyDomain.com:1433 domain\sqlServiceAccount











iv)The SQL Server service account must be trusted for delegation.









Once the delegation is set properly the bulk copy should work fine and we shouldn’t get any errors.





I am not delving deep into Kerberos troubleshooting as the same is well documented in another blog by my colleague here. The same can be referred if we still continue getting Kerberos related errors.






Author : Angshuman(MSFT), SQL Developer Engineer, Microsoft


Reviewed by : SMAT(MSFT), SQL Escalation Services, Microsoft

%3CLINGO-SUB%20id%3D%22lingo-sub-316231%22%20slang%3D%22en-US%22%3ESQL%20BULK%20COPY%20ERROR%20(%E2%80%9COperating%20system%20error%20code%205(Access%20is%20denied.)%E2%80%9D)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-316231%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Oct%2029%2C%202010%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EWhile%20there%20are%20various%20forms%20of%20bulk%20copy%20this%20blog%20specifically%20deals%20with%20copying%20data%20from%20a%20file%20into%20SQL%20Server.%20It%20deals%20about%20the%20specific%20error%20%E2%80%9COperating%20system%20error%20code%205(Access%20is%20denied.)%E2%80%9D%20which%20might%20crop%20up%20under%20certain%20circumstances%20when%20doing%20a%20bulk%20copy.%20For%20a%20while%20now%20I%20worked%20with%20a%20lot%20of%20DBAs%20and%20Developers%20bewildered%20with%20the%20problem%20and%20most%20of%20them%20complaining%20about%20the%20lack%20of%20good%20documentation%20about%20it%20and%20hours%20spent%20diagnosing%20in%20the%20wrong%20direction.%20If%20you%20are%20looking%20for%20details%20about%20bulk%20copy%20visit%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms130809(SQL.90).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms130809(SQL.90).aspx%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EYou%20run%20the%20following%20query%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBEGIN%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBULK%20INSERT%20ENVPOT_R%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFROM%20'%5C%5Cadvdev64%5CBulkTest%5Ctest_bulk_insert.txt'%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EWITH%20(%26nbsp%3B%20FIELDTERMINATOR%20%3D%20'%3B'%2C%26nbsp%3B%26nbsp%3B%20ROWTERMINATOR%20%3D%20'%5Cn')%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EEND%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAnd%20end%20up%20getting%20the%20following%20error%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66508iCDA30506E094167B%22%20%2F%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMsg%204861%2C%20Level%2016%2C%20State%201%2C%20Line%201%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ECannot%20bulk%20load%20because%20the%20file%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%22%20%3CA%3E%20%5C%5Cadvdev64%5CBulkTest%5Ctest_bulk_insert.txt%20%3C%2FA%3E%20%22%20could%20not%20be%20opened.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EOperating%20system%20error%20code%205(Access%20is%20denied.).%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20usual%20troubleshooting%20that%20DBAs%20do%20is%20to%20chase%20the%20%E2%80%9CAccess%20Denied%E2%80%9D%20error%20from%20a%20file%2Ffolder%20access%20perspective.%20Some%20of%20them%20are%20as%20follows.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ea)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Added%20%E2%80%9Cfull%E2%80%9D%20access%20to%20%E2%80%9Ceveryone%E2%80%9D%20(just%20temporary%20to%20test%20this)%20on%20the%20%3CEM%3E%20BulkTest%20%3C%2FEM%3E%20folder%20and%20still%20getting%20the%20same%20error.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eb)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Added%20%E2%80%9Cfull%E2%80%9D%20access%20to%20the%20SQL%20server%20service%20account%20on%20the%20%3CEM%3E%20BulkTest%20%3C%2FEM%3E%20folder%20and%20still%20get%20the%20same%20error.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ec)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20user%20is%20made%20a%20member%20of%20the%20%3CSTRONG%3E%20bulkadmin%20%3C%2FSTRONG%3E%20fixed%20server%20role.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMany%20DBAs%20come%20with%20prior%20experience%20on%20SQL%20Server%202000%20where%20the%20following%20was%20true.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EOnce%20a%20user%20was%20authenticated%2C%20access%20to%20external%20files%20was%20based%20on%20the%20security%20profile%20of%20the%20SQL%20Server%20process.%20When%20the%20SQL%20Server%20process%20had%20read%20access%20to%20a%20file%2C%20for%20a%20user%20that%20did%20not%20have%20access%20to%20the%20file%20but%20was%20a%20member%20of%20the%20%3CSTRONG%3E%20bulkadmin%20%3C%2FSTRONG%3E%20fixed%20server%20role%2C%20the%20user%20could%20import%20the%20file%20by%20using%20BULK%20INSERT%20and%20access%20the%20contents%20of%20the%20file.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBut%20that%20had%20a%20security%20issue%20and%20the%20way%20SQL%20Server%202005%20and%20later%20versions%20handle%20access%20to%20external%20files%20is%20different.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20following%20are%20the%20salient%20points%20you%20need%20to%20keep%20in%20consideration%20and%20are%20also%20mentioned%20in%20detail%20here%20%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms175915(SQL.90).aspx%22%20title%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms175915(SQL.90).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms175915(SQL.90).aspx%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ea)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20data%20file%20must%20be%20shared%20between%20the%20two%20computers%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eb)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20To%20specify%20a%20shared%20data%20file%2C%20use%20its%20universal%20naming%20convention%20(UNC)%20name%2C%20which%20takes%20the%20general%20form%20of%20%3CA%3E%20%3CSTRONG%3E%20%5C%5C%20%3C%2FSTRONG%3E%20%3CEM%3E%20Servername%20%3C%2FEM%3E%20%3CSTRONG%3E%20%5C%20%3C%2FSTRONG%3E%20%3CEM%3E%20Sharename%20%3C%2FEM%3E%20%3CSTRONG%3E%20%5C%20%3C%2FSTRONG%3E%20%3CEM%3E%20Path%20%3C%2FEM%3E%20%3CSTRONG%3E%20%5C%20%3C%2FSTRONG%3E%20%3CEM%3E%20Filename%20%3C%2FEM%3E%20%3C%2FA%3E%20.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ec)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20user%20account%20that%20is%20used%20by%20SQL%20Server%20must%20have%20been%20granted%20the%20permissions%20that%20are%20required%20for%20reading%20the%20file%20on%20the%20remote%20disk.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EBut%20there%20is%20another%20important%20consideration%20that%20needs%20to%20be%20taken%20care%20of%20when%20we%20have%20a%20setting%20as%20below%20and%20Windows%20authentication%20is%20being%20used.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66509iAD185166DCAC022F%22%20%2F%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EClient%20application%20from%20client%20machine%20%C3%A0%20SQL%20Server%20(SQL%20service%20account%20impersonating%20client%20account)%EF%83%A0%20%3CA%3E%20%5C%5CFile%20%3C%2FA%3E%20Server%20(impersonated%20client%20credentials)%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ea)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20We%20need%20to%20have%20CIFs%20SPN%20for%20the%20file%20server.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EWhenever%20a%20computer%20is%20joined%20to%20a%20domain%2C%20it%20is%20assigned%202%20SPN's%20by%20default%3A%20HOST%2FnetbiosName%2C%20and%20HOST%2FFQDN.com.%20netbiosName%20being%20the%20machine%20name%20of%20the%20computer%20being%20joined%20to%20the%20domain%2C%20and%20FQDN.com%20being%20the%20fully%20qualified%20machine%20name.%20These%20two%20SPN's%20use%20the%20generic%20%22HOST%22%20service%20type%20which%20includes%20all%20the%20various%20services%20that%20*come*be%20default%20with%20Windows.%20Therefore%2C%20if%20we%20connect%20to%20%3CA%20href%3D%22http%3A%2F%2FmachineName%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20http%3A%2F%2FmachineName%20%3C%2FA%3E%20or%20%3CA%20href%3D%22http%3A%2F%2FmachineName.company.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20http%3A%2F%2FmachineName.company.com%20%3C%2FA%3E%20%2C%20we%20will%20already%20have%20SPN's%20set%20that%20will%20handle%20Kerberos%20when%20using%20those%20names.%20When%20trying%20to%20connect%20to%20%3CA%3E%20%5C%5CmachineName%5CSomeShareName%20%3C%2FA%3E%20we%20would%20be%20all%20set%20for%20Kerberos%20(UNC's%20need%20a%20%22CIFS%22%20SPN%20which%20is%20included%20under%20%22HOST%22%20also).%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EComplete%20list%20of%20the%20different%20service%20types%20included%20in%20HOST%20of%20can%20be%20found%20in%20%3CA%20href%3D%22http%3A%2F%2Fwww.microsoft.com%2Ftechnet%2Fprodtechnol%2Fwindowsserver2003%2Ftechnologies%2Fsecurity%2Ftkerbdel.mspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20this%20%3C%2FA%3E%20technet%20article.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eb)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Configuring%20Kerberos%20delegation%20on%20the%20SQL%20Server%20box.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20requirements%20are%20as%20follows.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ei)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20A%20domain%20user%20running%20the%20query%20from%20management%20studio%20must%20not%20have%20the%20Account%20is%20sensitive%20and%20cannot%20be%20delegated%20selected%20option.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66510iDC0DB2DC48EE0A3C%22%20%2F%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eii)%20SPNs%20must%20be%20registered%20for%20the%20SQL%20Server%20service%20if%20the%20service%20account%20is%20a%20domain%20account.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eiii)%26nbsp%3B%20The%20client%20must%20be%20connecting%20to%20the%20SQL%20using%20TCP.%20%3CA%20href%3D%22http%3A%2F%2Fsupport.microsoft.com%2Fdefault.aspx%3Fscid%3Dkb%3BEN-US%3B811889%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20http%3A%2F%2Fsupport.microsoft.com%2Fdefault.aspx%3Fscid%3Dkb%3BEN-US%3B811889%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20service%E2%80%99s%20SPN%20must%20be%20registered%20by%20a%20domain%20administrator%20if%20the%20service%20account%20is%20a%20domain%20user%20account.%20If%20the%20service%20account%20uses%20the%20computer%E2%80%99s%20account%2C%20then%20the%20process%20can%20register%20by%20itself%20or%20the%20local%20administrator%20can%20register%20it%20by%20using%20Setspn.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAt%20a%20command%20prompt%2C%20type%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E%20setspn%20%E2%80%93L%20Account%20%26nbsp%3Bdomain%5CsqlServiceAccount%20%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThese%20two%20SPNs%20for%20SQL%20service%20account%20must%20come%20up%20for%20delegation%20to%20properly%20function%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E2%80%A2One%20for%20MSSQLSvc%2FHost%3A1433%2C%20where%20Host%20is%20the%20name%20of%20the%20host%20computer.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%E2%80%A2One%20for%20MSSQLSvc%2FFQDN%3A1433%20where%20FQDN%20is%20the%20fully%20qualified%20domain%20name%20of%20the%20computer%20running%20SQL%20Server%20.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20port%20number%20at%20the%20end%20may%20vary%20depending%20on%20the%20actual%20port%20the%20SQL%20Server%20is%20listening%20on.%20For%20the%20sake%20of%20brevity%20I%20have%20assumed%20the%20default%20port%201433.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20there%20are%20no%20MSSQLSvc%20SPNs%20listed%20or%20there%20is%20an%20SPN%20missing%2C%20then%20we%20need%20to%20add%20the%20appropriate%20SPN%20using%20the%20setspn%20%E2%80%93A%20command%20for%20delegation%20to%20work%20properly.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAt%20a%20command%20prompt%2C%20type%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E%20setspn%20-A%20MSSQLSvc%2F%26lt%3B%20Host%20%26gt%3B%3A%3CPORT%3E%20%3CSQL_SERVICE_ACCOUNT%3E%20%3C%2FSQL_SERVICE_ACCOUNT%3E%3C%2FPORT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E%20setspn%20-A%20MSSQLSvc%2F%3CFQDN%3E%3A%3CPORT%3E%20%3CSQL_SERVICE_ACCOUNT%3E%20%3C%2FSQL_SERVICE_ACCOUNT%3E%3C%2FPORT%3E%3C%2FFQDN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EA%20sample%20is%20as%20below%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E%20setspn%20-A%20MSSQLSvc%2FMySQLServer%3A1433%20domain%5CsqlServiceAccount%20%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E%20setspn%20-A%20MSSQLSvc%2FMySQLServer.MyDomain.com%3A1433%20domain%5CsqlServiceAccount%20%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Eiv)The%20SQL%20Server%20service%20account%20must%20be%20trusted%20for%20delegation.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66511i387FF75C97D898CC%22%20%2F%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EOnce%20the%20delegation%20is%20set%20properly%20the%20bulk%20copy%20should%20work%20fine%20and%20we%20shouldn%E2%80%99t%20get%20any%20errors.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EI%20am%20not%20delving%20deep%20into%20Kerberos%20troubleshooting%20as%20the%20same%20is%20well%20documented%20in%20another%20blog%20by%20my%20colleague%20here.%20The%20same%20can%20be%20referred%20if%20we%20still%20continue%20getting%20Kerberos%20related%20errors.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAuthor%20%3A%20Angshuman(MSFT)%2C%20SQL%20Developer%20Engineer%2C%20Microsoft%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EReviewed%20by%20%3A%20SMAT(MSFT)%2C%20SQL%20Escalation%20Services%2C%20Microsoft%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-316231%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Oct%2029%2C%202010%20%26nbsp%3BWhile%20there%20are%20various%20forms%20of%20bulk%20copy%20this%20blog%20specifically%20deals%20with%20copying%20data%20from%20a%20file%20into%20SQL%20Server.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-316231%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EStorage%20Engine%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jan 15 2019 01:17 PM
Updated by: