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

xp_cmdshell is now locked out ... Expand / Collapse
Author
Message
Posted Monday, April 27, 2009 11:05 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 24, 2014 11:56 PM
Points: 15, Visits: 139
As xp_cmdshell is generally not available (unless one enables it, which some companies frown upon), a possible replacement for the code that checks for file existence is using xp_fileexist. Therefore the lines in between "temp proc to check backup file existence" become:

-- START create temp proc to check backup file existence
CREATE PROCEDURE dbo.#prFileExists
@path varchar(300) ,
@p2 int OUTPUT
AS BEGIN
IF object_id('tempdb..#cmdshell') IS NOT NULL
DROP TABLE #cmdshell
CREATE TABLE #cmdshell ([File Exists] int, [File is a Directory] int, [Parent Directory Exists] int)
INSERT INTO #cmdshell exec master..xp_fileexist @path

SELECT @p2 =[File Exists] from #cmdshell
END
GO
-- END create temp proc to check backup file existence
Post #705510
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse