Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

Keeping a Database Server Healthy

0.00/5 (No votes)
12 Apr 2011CPOL 3.7K  
Actually, we think xp_cmdshell is not safe enough, and need to be enabled using surface area configuration explicitly (SQL 2005). We use xp_delete_file instead, sample code:DECLARE @l_Runtime DATETIME, @l_BackupFileName VARCHAR(256), @l_FileExists INTSET...
Actually, we think xp_cmdshell is not safe enough, and need to be enabled using surface area configuration explicitly (SQL 2005). We use xp_delete_file instead, sample code:
SQL
DECLARE @l_Runtime        DATETIME,
        @l_BackupFileName VARCHAR(256),
        @l_FileExists     INT
SET @l_Runtime = GETDATE()
SET @l_BackupFileName = ...
EXEC master.dbo.xp_fileexist @l_BackupFileName, @l_FileExists OUTPUT
IF @l_FileExists = 1
BEGIN
   EXECUTE master.dbo.xp_delete_file 0, @l_BackupFileName, '', @l_Runtime
END

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)