Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: Yesterday @ 2:27 PM
Points: 132, Visits: 910
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


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 1:02 PM
Points: 1,276, Visits: 2,197
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