Need to replace a string in a string with a string

  • I am trying to replace a string variable within a string in a field as such \\Computername\FTP\<companyname>. I want to exchange the <companyname> and update it with an actual company name. The field type is a varchar and I am just trying to zip through the table and replace all the variables with actual values within that field. Can anyone help with this?

    Thanks,

    Chris

  • DECLARE @CompanyName VARCHAR(xxx)

    SET @CompanyName = 'Name of Company'

    UPDATE MyTable

    SET MyField = REPLACE(MyField, '<companyname>', @CompanyName)

    WHERE [Criteria go here]

  • Perfect, it worked great!!! Thanks

    quote:


    DECLARE @CompanyName VARCHAR(xxx)

    SET @CompanyName = 'Name of Company'

    UPDATE MyTable

    SET MyField = REPLACE(MyField, '<companyname>', @CompanyName)

    WHERE [Criteria go here]


Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply