Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

exec DTS within a SP:  xp_cmdshell failed to execute

Posted on 2007-11-27
2
Medium Priority
?
1,373 Views
Last Modified: 2008-03-23
(SQL2K) -2147467259, xp_cmdshell failed to execute because current security context is not sysadmin and proxy account is not setup correctly.  For more information, refer to Book Online, search for topic related to xp_sqlagent_proxy_account.

The above error message is generated as a result of Access VBA (below) calling the attached code snippet/SP:

sSQL = "exec spm_create_stand_alone '" & sCase & "'"
rs = gcnCASES.Execute(sSQL).Fields(0).Value

I could use some help getting past this, as my knowledge of SQL users/roles/proxy agents is nearly nil.

TIA
Jim

CREATE PROC spm_create_stand_alone(@cases_id varchar(50)) AS
 
SET NOCOUNT ON
 
/*
-- TESTING ONLY
use dbname
Declare @cases_id varchar(50)
SELECT @cases_id = '15322 FOO-3'
*/
 
Declare @bail_message varchar(100)
 
-- Make sure the case was pushed 
IF NOT EXISTS (SELECT cases_id FROM CLOG_CASE_LOG WHERE cases_id=@cases_id)
	begin
	SELECT @bail_message = 'Case ' + @cases_id + 'has not been extracted.'
	goto bail
	end
 
DELETE FROM MY_TABLE
 
INSERT INTO MY_TABLE (CASES_ID) VALUES (@cases_id)
 
-- Run the DTS package that writes to the Access database
exec master.dbo.xp_cmdshell 'dtsrun /Sserver /Utheuser /Pthepassword /Nthedtspackage, no_output
 
SELECT '1' as RETURN_VALUE
goto ex
 
-- This code processes if the deletion was unsuccessful based on any of the above criteria. 
bail:
	begin
	SELECT @bail_message as RETURN_VALUE
	goto ex
	end
 
ex:
GO

Open in new window

0
Comment
Question by:Jim Horn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
James Murrell earned 800 total points
ID: 20362105
that error means permissions........ would suggest a permissions error or incorrectly
specified location, also this error occurs when you leave spaces between the switches and their values
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 21191498
Sorry for abandoning the question.

I found out that xp_cmdshell can't be called like this, as it would enable calling code to pretty much do anything.
I'm going to lower points to 200 and award to you, as your comment pointed in that direction.

Jim
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question