SQL Question

SaiLoveAll
SaiLoveAll used Ask the Experts™
on
I have a column in sql, which has value like “ATTACHMENT: Service Reports\East SRO\sro 10238 Service Report forever .pdf>” I need to replace “ATTACHMENT: with \\srv-nass01\fieldservice\. Rest of the information remains same. Like this \\srv-nas01\fieldservice\2009 Service Reports\East SRO\sro 10238 Service Report forever .pdf> How do I do using sql script?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018

Commented:
Use REPLACE like

SELECT REPLACE ( 'ATTACHMENT: Service Reports\East SRO\sro 10238 Service Report forever .pdf>' , 'ATTACHMENT: ' , '\\srv-nass01\fieldservice\.' )
Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018

Commented:
>> \\srv-nas01\fieldservice\2009 Service Reports\East SRO\sro 10238 Service Report forever .pdf>

Kindly let me know where is this 2009 coming from..
Include in Replace section if required..

Commented:
UPDATE <tablename>
   SET REPLACE(<fieldname>
              ,'ATTACHMENT: '
              ,'\\srv-nass01\fieldservice\')
 WHERE <fieldname> LIKE 'ATTACHMENT:%'


Substitute <tablename> with your actual table name and <fieldname> with your actual field name.  Be aware of the space after the colon on the third line.


Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018
Commented:
If you want to update the table with this new value then

UPDATE ur_table_name
SET ur_column_name = REPLACE(ur_column_name,'ATTACHMENT: ','\\srv-nass01\fieldservice\')
WHERE ur_column_name LIKE 'ATTACHMENT:%'
Commented:
Oops.  Syntax error!
UPDATE <tablename>
  SET <fieldname> = REPLACE(<fieldname>
             ,'ATTACHMENT: '
             ,'\\srv-nass01\fieldservice\')
WHERE <fieldname> LIKE 'ATTACHMENT:%'


 Sorry about that!
Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018

Commented:
angelIII,
I would recommend

Split between 26434350 and 26434379

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial