Files
sql-scripts/DBG - change dump device for arizona to u drive.sql
Schork Thierry (Galenica - ADM) 63d058a7eb added files from swmgmt03
2025-09-22 09:00:00 +02:00

50 lines
1.7 KiB
SQL

if object_id('tempdb..#drives') is not null
drop table #drives
create table #drives(stdout varchar(255));
insert into #drives
exec xp_cmdshell 'dir u:'
--select * from #drives where stdout is not null
if (select count(1) from #drives where stdout is not null) > 2
begin
print 'drive U exists';
IF EXISTS (
SELECT *
FROM [sys].[backup_devices]
WHERE name='Arizona_Dump' AND [physical_name] LIKE 'D:%'
)
BEGIN
EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_Dump',@delfile = NULL;
PRINT 'Dump device Arizona_Dump removed';
END
IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_Dump')
BEGIN
EXEC master.dbo.sp_addumpdevice @devtype = N'disk',
@logicalname = N'Arizona_Dump',
@physicalname = N'U:\Arizona_Dump.bak';
PRINT 'Dump device Arizona_Dump created on U drive';
END
IF EXISTS (SELECT * FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU' AND [physical_name] LIKE 'D:%')
BEGIN
EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_dump_SECU',@delfile = NULL
PRINT 'Dump device Arizona_dump_SECU removed';
END
IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU')
BEGIN
EXEC master.dbo.sp_addumpdevice @devtype = N'disk',
@logicalname = N'Arizona_dump_SECU',
@physicalname = N'U:\Arizona_dump_SECU.bak';
PRINT 'Dump device Arizona_dump_SECU created on U drive';
END
end
else
begin
print 'drive U does not exists'
end
if object_id('tempdb..#drives') is not null
drop table #drives