January 13, 2009 at 2:17 am
Hi,
i want to insert into a variable the backup path of a specific database
without the backup name only the path (D:\backup\databasename\).
i use this syntax to view the whole backup path but i don't know how to remove the backup name from the path.
the path and backup name are changes from one server to another but the backup file is always start with databasename and end with .bak
can you help me with the current syntax?
THX
select top 1 bset.database_name ,bfamily.physical_device_name,bset.backup_finish_date from
backupmediafamily bfamily,backupset bset
where bset.media_set_id = bfamily.media_set_id
and bset.database_name = 'databasename'
order by bset.backup_finish_date desc
January 13, 2009 at 2:45 am
thx.
i need the path,not the filename.
January 13, 2009 at 2:58 am
This will work
DECLARE @file VARCHAR(100)
SET @file = 'D:\backup\databasename\Backupname.bak'
SELECT LEFT(@file, LEN(@file) - CHARINDEX('\',REVERSE(@file)))
[font="Verdana"]Markus Bohse[/font]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply