gillers322
gillers322

Reputation: 249

SQL Replace with new data

I want to replace data in a field with new data that has a URL and also add two other fields from the table. So far I have:

(replace([DBS_Cert],'pres://Default.STAFFMANAGEMENT/STAFF/',''))

This produces the file name i.e certificate.pdf

What I need is the field with the result to be:

https://s3-eu-west-1.amazonaws.com/Certificates/[ColumnField]/[ColumnField]/certificate.pdf

I can't figure out how to make add the URL and Column Fields into (replace([DBS_Cert],'pres://Default.STAFFMANAGEMENT/STAFF/',''))

Any help would be appreciated.

Thanks

Upvotes: 0

Views: 57

Answers (1)

Dzmitry Paliakou
Dzmitry Paliakou

Reputation: 1627

Concatenate strings using '+'. And don't forget to convert types of your ColumnFields to varchar.

replace([DBS_Cert],
'pres://Default.STAFFMANAGEMENT/STAFF/',
'https://s3-eu-west-1.amazonaws.com/Certificates/' + 
    CAST([ColumnField] as varchar(500)) + '/' + 
    CAST([ColumnField] as varchar(500)) + '/certificate.pdf')

Upvotes: 1

Related Questions