![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#3
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#4
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#5
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#6
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#7
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#8
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#9
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
#10
| |||
| |||
|
|
I used the code below, what the difference between @command and fullPathName? |
|
I used the code below, what the difference between @command and fullPathName? CREATE TABLE #BackupFiles (FullPathName NVARCHAR(256)) DECLARE @Command NVARCHAR(256) SET @Command = 'master.dbo.xp_cmdshell "DIR ' + 'D:\Program Files\Microsoft SQL Server\MSSQL\Backup\' + '*.* /B /S"' INSERT INTO #BackupFiles EXEC (@Command) DECLARE @DeleteFiles NVARCHAR(4000) DECLARE file_cursor CURSOR FOR SELECT ' exec xp_cmdshell ''DEL "' + FullPathName + '"''' +CHAR(13)+CHAR(10) FROM #BackupFiles WHERE (FullPathName LIKE '%_%.BAK') -- Trims punctuation and space from date time string AND RIGHT(FullPathName,16) REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), DATEADD(month, -1, GETDATE()),120) ,' ',''),':',''),'-','') OPEN file_cursor FETCH NEXT FROM file_cursor INTO @DeleteFiles WHILE @@FETCH_STATUS = 0 BEGIN EXEC (@DeleteFiles) FETCH NEXT FROM file_cursor INTO @DeleteFiles END CLOSE file_cursor DEALLOCATE file_cursor -- KPoku |
![]() |
| Thread Tools | |
| Display Modes | |
| |