Re: bcp data export from SQL Server to file

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 05/03/04


Date: Mon, 3 May 2004 08:04:06 -0500

If you are using xp_cmdshell, the OS security context will be the SQL Server
service account when executed by a sysadmin server role member. When
executed by a non-sysadmin user, the security context will be the SQL Server
Agent proxy account. The proxy account can be configured from Enterprise
Manager under the SQL Server Agent properties Job System tab when the 'only
allow users with sysadmin privileges...' box is unchecked'.

If you continue to have problems, please post the relevant code.

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"Nikolai Todorov" <nikolai.todorov@smcon.com> wrote in message
news:%23rDB6uQMEHA.3052@TK2MSFTNGP12.phx.gbl...
> Yes, and this works just fine.
>
> But my point is to do it threw my .NET application
> The same command generated by my application, when I paste it in the
command
> prompt it succeeds. But when I execute it threw the application - nothing
> hapens.
>
> So my problem is not that my command doesn't execute, but that it doesn't
> execute threw a VS.NET applicaton, using ADO.NET components.
>
> My suggestion is that I have a permission problems, but I don't know where
> they could be.
>
> "Uri Dimant" <urid@iscar.co.il> wrote in message
> news:eWBuQLQMEHA.1340@TK2MSFTNGP12.phx.gbl...
> > Nikolai
> > create table ww
> > (
> >  col1 int,
> >  col2 varchar(50),
> >  col3 varchar (50)
> > )
> >
> > insert into ww values (47,'ReadyShip','(503)888-999')
> > insert into ww values (48,'MyShipper','(503)1212-454')
> > insert into ww values (49,'ReadyShip','(45)888-999')
> > insert into ww values (50,'MyShipper','(545)1212-454')
> >
> > exec master..xp_cmdshell 'BCP northwind..ww IN
> > d:\test1.txt -c -C850 -SServer -Usa -Ppass'
> >
> >
> >
> >
> > "Nikolai Todorov" <nikolai.todorov@smcon.com> wrote in message
> > news:uMeM8EQMEHA.3668@TK2MSFTNGP11.phx.gbl...
> > > I have not tried a stored procedure, because I think that the reason
is
> > > somewhere in the permissions wich the .NET application, the export
> > > directory, or sql server account has. But I can't find what exactly
is.
> I
> > > suppose the stored procedure should pass the same way the sqlcommand
do.
> > >
> > >
> > > "Uri Dimant" <urid@iscar.co.il> wrote in message
> > > news:ekK5G7PMEHA.1900@TK2MSFTNGP10.phx.gbl...
> > > > Nikolai
> > > > Have you tried to wrap the BCP coomand with stored procedure and
then
> > just
> > > > call it from .NET application?
> > > >
> > > >
> > > >
> > > > "Nikolai Todorov" <nikolai.todorov@smcon.com> wrote in message
> > > > news:eraMd4PMEHA.3348@TK2MSFTNGP09.phx.gbl...
> > > > > I have a bcp command which exports a SQL table to a file in a
> > directory.
> > > > > When I start the command from the command prompt it works just
fine.
> > > > > But when I try to start it threw a .NET application using a
> SqlCommand
> > > > > object with a parameter the string of the bcp command - nothing
> > happens!
> > > > The
> > > > > ExecuteNonQuery() method returns -1.
> > > > > Where can be the problem, regarding that the SQL Server is not on
my
> > > > > machine.
> > > > >
> > > > > Thank you in advance
> > > > >
> > > > > --
> > > > > Nikolai Todorov
> > > > >
> > > > > Software Engineer
> > > > > SM Consulta Ltd.
> > > > > 86, Cherni Vrah Blvd., Office #1
> > > > > Sofia 1407
> > > > > Bulgaria
> > > > > Phone: +359 2 9621905
> > > > >            +359 2 9625261
> > > > > FAX:    +359 2 9624764
> > > > > Mobile: +359 88 8855802
> > > > > http://www.smcon.com
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Execute Persmission denied on object sp_OACreate
    ... > I logged in as that user, tried to execute the DTS ... which then launches the DTS package using the sp_OA* procs? ... account is used during proc execution. ... > proxy account to use in the Job Systems tab of SQL Server Agent ...
    (microsoft.public.sqlserver.security)
  • Execute Process Task not failing, but not executing the batch comm
    ... I can execute the following command from the windows "Run" prompt and it ... Might I have something set weird in SQL Server? ... server being by default configured to run as localsystem account, ...
    (microsoft.public.sqlserver.dts)
  • Re: xp_cmdshell issue, local system
    ... please make sure the service account SQL Server running under has ... this error may be because the SQL Server service ... account doesn't have the rights necessary to change security context to the ... >I want to give access to a regular user to execute xp_cmdshell. ...
    (microsoft.public.sqlserver.security)
  • Re: dts or xp_cmdshell permissions
    ... You could have the users execute the package ... Change the SQL Server or SQL Server Agent Service ... >> Account Without Using SQL Enterprise Manager in SQL Server ...
    (microsoft.public.sqlserver.tools)
  • Re: Execute Persmission denied on object sp_OACreate
    ... > SQL Server is creating a job behind the scenes. ... > permissions. ... > SA account password and gaining access to the database. ... >>> How can get a user permissions to execute these stored procedures ...
    (microsoft.public.sqlserver.security)

Loading