Showing posts with label bcp. Show all posts
Showing posts with label bcp. Show all posts

Tuesday, March 27, 2012

error 1813 with xp_cmdshell

Hi all,
I am trying to launch a xp_cmdshell from a stored procedure to execute a BCP
.
This error occured when my sp is called :
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. -->
System.Data.SqlClient.SqlException: A severe error occurred on the current
command.
The results, if any, should be discarded. xp_cmdshell failed to execute,
error 1813 occured while executing CreateProcessAsUserW.
I use SQLServer 2000 SP4 and a system account to launch the xp_cmdshell. The
SQL server agent log on with this same account.
Any idea?
I will appreciate any help.
Regards.
LGHi,
xp_cmdshell executes with the security contect of the SQL Agent Proxy
account when executed by non symin users. This requires you to allow
non-symin users to execute xp_cmdshell (uncheck the 'Only users with
symin privileges...' checkbox under SQL Server Agent properties --> Job
System) and specify a Windows account for the SQL Agent proxy with the
permissions needed to run you application).
See the below URL:-
http://support.microsoft.com/defaul...b;en-us;Q264155
Thanks
Hari
SQL Server MVP
"Laurent G" <LaurentG@.discussions.microsoft.com> wrote in message
news:13FBAEA9-A146-49E0-A42C-1B939CC3DA06@.microsoft.com...
> Hi all,
> I am trying to launch a xp_cmdshell from a stored procedure to execute a
> BCP.
> This error occured when my sp is called :
> System.Web.HttpUnhandledException: Exception of type
> System.Web.HttpUnhandledException was thrown. -->
> System.Data.SqlClient.SqlException: A severe error occurred on the current
> command.
> The results, if any, should be discarded. xp_cmdshell failed to execute,
> error 1813 occured while executing CreateProcessAsUserW.
> I use SQLServer 2000 SP4 and a system account to launch the xp_cmdshell.
> The
> SQL server agent log on with this same account.
> Any idea?
> I will appreciate any help.
> Regards.
> LG|||Thanks a lot Hari, it works now.
"Hari Pra" wrote:

> Hi,
> xp_cmdshell executes with the security contect of the SQL Agent Proxy
> account when executed by non symin users. This requires you to allow
> non-symin users to execute xp_cmdshell (uncheck the 'Only users with
> symin privileges...' checkbox under SQL Server Agent properties --> Job
> System) and specify a Windows account for the SQL Agent proxy with the
> permissions needed to run you application).
> See the below URL:-
> http://support.microsoft.com/defaul...b;en-us;Q264155
>
> Thanks
> Hari
> SQL Server MVP
> "Laurent G" <LaurentG@.discussions.microsoft.com> wrote in message
> news:13FBAEA9-A146-49E0-A42C-1B939CC3DA06@.microsoft.com...
>
>

Sunday, February 26, 2012

ERROR : Host-file columns may be skipped only when copying into the Server

Hi All,

I need to make a query from the SQL Server 2K and save this data as an XML file. What i am trying to do is to execute a bcp utility as follows:

EXEC master..xp_cmdshell 'bcp "SELECT CustID,CustName,CustSurname,CustEmail FROM myOwenDB..T_Customers FOR XML RAW" queryout "c:\customers.xml" -fc:\bcp.fmt -Sservername -Usa -Ppwd -C RAW -r -t'

with bcp.fmt file formatted as

8.0
4
1 SQLCHAR 0 9 "\t" 1 CustID Turkish_CI_AS
2 SQLCHAR 0 100 "\t" 2 CustName Turkish_CI_AS
3 SQLCHAR 0 100 "\t" 3 CustSurname Turkish_CI_AS
4 SQLCHAR 0 100 "\t" 4 CustEmail Turkish_CI_AS

The error is as follows:

Error = [Microsoft][ODBC SQL Server Driver]Host-file columns may be skipped only when copying into the Server

Does anyone have an idea about the problem? Also other techniques to generate XML file are also welcomed:)

Thanks in advance,

Bahtiyar KARANLIKYour select statment only returns one column and you are using a format file that says bcp will be receiving four columns from the select statment.|||Hi,
How can my SQL statement can return only one column? When i execute the statement via Query Analyzer it displays the correct information?

Am i missing a point??

Bahtiyar KARANLIK|||If you execute
SELECT CustID,CustName,CustSurname,CustEmail FROM myOwenDB..T_Customers
In QA you will get four columns, CustID, CustName,CustSurname and CustEmail.

If you execute
SELECT CustID,CustName,CustSurname,CustEmail FROM myOwenDB..T_Customers FOR XML RAW
In QA you will have a resultset with one column. Within the one column you will have an XML string that contains the four above mentioned columns, but they will be contained in one column!

If you execute
select au_id,au_lname,phone,contract from pubs.dbo.authors

you should get something like:

au_id au_lname phone contract
---- ------------ ---- ---
172-32-1176 White 408 496-7223 1

If you execute
select au_id,au_lname,phone,contract from pubsdbo.authors for xml raw

you should get something like:

XML_F52E2B61-18A1-11d1-B105-00805F49916B
------------------------
<row au_id="172-32-1176" au_lname="White" phone="408 496-7223" contract="1"/>

The first has four colums in the result set the second has only one.