Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BULK INSERT ERROR 21

Author  Topic 

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-10 : 10:52:38
Good Morning,

I really have a strange problem. Im running Sql server 2008 on a Windows 2008 server R2 (64 bit).

I do all my test directly on the server in Windows authentication mode !

If I start sql server management studio and log on with the administrator (domain account) and I issue this command
BULK INSERT DBO.CIES FROM 'D:\brossard\CIES.txt' with ( KEEPIDENTITY,ROWS_PER_BATCH=1000,TABLOCK,MAXERRORS=1,CODEPAGE='RAW')

Everything work fine all row are inserted in the table !, so all the credential for Sqlserver and all the security for my administrator user account are ok !.

If I issue the SAME command from my program and my program connect to the SQL server with Windows authentication and remember that I'm running all my test FROM the Windows Server 2008 where the SQL Server is installed and drive D: is a local drive, I received
Message SQL Server 4861, state 1, severity:
Cannot bulk load because the file "D:\brossard\CIES.txt" could not be opened. Operating system error code 21(error not found).

I ran the Sql profiler to be sure that my program is using the administrator account of the domain to login to the Sql server 2008 and my program use the right account !

I really don't know WICH security I missed :(

Can someone give me a clue !

BTW running procmon to monitor the acces to the file CIES.TXT, I see that BOTH studio management and my program are using the administrator account of my domain, BUT the authentication ID are different ??

It's probably a Windows server 2008 problem, but I'm not sure !

best regards,

Sylvain Robert


russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-10 : 12:23:10
Account you're connecting with via your application, doesn't have permission.

see here: http://msdn.microsoft.com/en-us/library/ms188365.aspx
Go to Top of Page

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-10 : 12:43:46
Russel,

quote:
Originally posted by russell

Account you're connecting with via your application, doesn't have permission.

see here: http://msdn.microsoft.com/en-us/library/ms188365.aspx



As I stated in my problem description BOTH studio manager and my application are using Windows authentication, I'm directly on the server and I'm logged with the domain administrator account.

Best Regards,

Sylvbain robert
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-10 : 14:45:34
is BUILTIN\Administrators assigned to sysadmin server role?

are all domain admins included in the host servers Administrators group?

is sql service account local admin?
Go to Top of Page

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-11 : 06:20:23
Russell,

>>is BUILTIN\Administrators assigned to sysadmin server role?

Not the group, but Domain\Administrator is !

>>are all domain admins included in the host servers Administrators >>group?

There is no HOST server, Sql server is on the Windows 2008 server, all the test are made locally on the Windows 2008 server logged as Domain\Administrator


>>is sql service account local admin?

The sql service is started with Domain\Administrator and the directory where the file reside d:\brossard Domain\Administrator has full control !

I begin to think that I'll have to reinstall mt Sql Server 2008
Best Regards,

Sylvain
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-11 : 10:17:28
The host server is the Windows server hosting SQL Server. If the account isn't explicitly granted permission, then it doesn't have permission. Just being a member of the domain administrators group or calling the account Administratpr, doesn't grant permission to anything.

I very much doubt that you need to reinstall sql. You have a permissions issue is all.
Go to Top of Page

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-11 : 11:01:29
Russell,

The SQL SERVER 2008 is installed in the W2K8 server that I am logged on when doing all my test that's why I told you that there is no other HOST involved !

I know that is a permission issue somewhere, Im really searching hard to find it ! :). I' m sure of the account used for the SQL SERVER instance service and the Windows authetication that Iused and the security set on the directory and file used in the bulk statement, remember it work well with Studio management of Sql server but not with my application sending the SAME Tsql command to the Sql server !

BTW the same program on another W2K3 server with Sql2005 installed work perfectly !. Wich permission my program need on W2K8 server R2 to be able to do that kind of TSQL command ?

Best REgards,

Sylvain

quote:
Originally posted by russell

The host server is the Windows server hosting SQL Server. If the account isn't explicitly granted permission, then it doesn't have permission. Just being a member of the domain administrators group or calling the account Administratpr, doesn't grant permission to anything.

I very much doubt that you need to reinstall sql. You have a permissions issue is all.

Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-11 : 11:25:21
what happens if, you issue: xp_cmdshell 'dir D:\brossard\CIES.txt'
Go to Top of Page

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-11 : 11:57:54
Russell,

I leave the office, I'll be back monday, I'll wrote a program that is sending that Tsql commande on Monday I'll keep you inform !

Best Regards,

Sylvain

quote:
Originally posted by russell

what happens if, you issue: xp_cmdshell 'dir D:\brossard\CIES.txt'

Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-12-11 : 12:04:47
Have a good weekend
Go to Top of Page

SylvainRobert
Starting Member

6 Posts

Posted - 2009-12-14 : 05:29:11
Russell,

I finally found the problem this morning, the programmer has hardcoded the Servername and the BD instead of reading the INI who give the connection detail.

I really apologize and I'm sorry that you waste your precious time !

Best Regards,

Sylvain

quote:
Originally posted by russell

Have a good weekend

Go to Top of Page
   

- Advertisement -