Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get output from xp_cmdshell 1

Status
Not open for further replies.

maswien

Technical User
Joined
Sep 24, 2003
Messages
1,286
Location
CA

I want save the output of command xp_cmdshell '...' to a table, is this possible?

something like:

insert into myTable exec (xp_cmdshell '...' )

Is there any other way to get the output saved?
 
nope not like that.

You maybeable to pipe the output to a txt file and then bcp it in to you table. Depending on what you xp_cmdshell task does.

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
MDX I hate to disagree, but you can totaly do what maswien asked. This works perfectly on one of my servers.

Code:
create table #Temp1 
(output varchar(1000))

insert into #Temp1
exec xp_cmdshell 'dir c:\'

select *
from #Temp1

drop table #Temp1

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Well I stand corrected. I have known people try other methods in the past that didn't work. Star for you Denny

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 


Thanks denny! I guess it's a very good tip for every DBA.
 
thanks guys :-)

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top