Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Capture t-sql error occured in xp_cmdshell Expand / Collapse
Author
Message
Posted Tuesday, October 15, 2013 11:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 7, 2016 5:08 PM
Points: 137, Visits: 1,018
Is there a way to capture the t sql error occured while running the tsql script via xp_cmdshell ???
Help is really appreciated!!
Post #1504878
Posted Tuesday, October 15, 2013 1:44 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 1:17 PM
Points: 1,867, Visits: 3,094
You can capture the output from a command executed with xp_CMDshell by doing something like this:

DECLARE @CMD VarChar(500)
DECLARE @Results TABLE
(
ID Int Not Null IDENTITY(1,1),
Line VarChar(256)
)

SET @CMD = 'dir C:\'

INSERT INTO @Results (Line)
EXEC xp_CMDShell @CMD

SELECT *
FROM @Results

Post #1504951
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse