Forum Discussion
nasdba
Jun 26, 2021Copper Contributor
file concatenation
Hi ,
I am writing a proc to handle backup location for a restore script. can anyone suggest me how to generate complete path using both locations as below and final path name silty different as we need to ignore first part from location 2 ( i.e K:\backup\)
Backup location1 : \\backupserver\sqlbackup
Backup location 2 : K:\Backups\localserver\PRD_DW_ABCD\FULL\localserver_PRD_DW_ABCD_FULL_20210621_140002_1.bak
I am looking for final location by using both backup locations (concatenation and remove part of k:\backup from send backup location )
Path should be as
\\backupserver\sqlbackup\localserver\PRD_DW_ABCD\FULL\localserver_PRD_DW_ABCD_FULL_20210621_140002_1.bak
- olafhelperBronze Contributor
nasdba , do you mean a simple replace?
declare @base nvarchar(400) = N'\\backupserver\sqlbackup' declare @path nvarchar(400) = N'K:\Backups\localserver\PRD_DW_ABCD\FULL\localserver_PRD_DW_ABCD_FULL_20210621_140002_1.bak' select replace(@path, N'K:\Backups', @base);