Search and replace entire column value SQL Server
<p>My first time at Stack Overflow. I need help creating a procedure that searches for a specific string and replaces the entire value of that column in the database to another string. for example here is the data i need to search for and replace it with: </p>

<pre><code>search column:         replace column:
1.'rbc inv',           1.'RBC dominion securities',
2.'rbc dom',           2.'RBC dominion securities',
3.'RBC'                3.'RBC Bank'
</code></pre>

<p>I receive the above in Excel format and I upload it as a table into SQL Server then run my script as you can see below. there are column that currently have the string RBC investment for Seniors' that needs to be replaced with 'RBC dominion securities (number 1 above). </p>

<p>My issue is that the <code>replace</code> function doesn't work when the search columns are very similar to each other as you can see above and it only replaces the string found and not the entire cell or column value in the database. I tried putting a line to set the column value to null before it replaces it with the new value and failed multiple times. I have a way to do this manually one at a time but when I receive an excel sheet with over 300 columns that I need to look for and replace is very frustrating. Can anyone help? Please and thank you. </p>

<p>Here is the script I created. </p>

<pre><code>SET NOCOUNT ON;

DECLARE @searchColumnValue nvarchar(max), @replaceColumnValue nvarchar(max)

DECLARE replace_cursor CURSOR FOR 
SELECT searchColumn, replaceColumn             -
FROM dbo.search

OPEN replace_cursor

FETCH NEXT FROM replace_cursor
INTO @searchColumnValue , @replaceColumnValue 
WHILE @@FETCH_STATUS = 0
BEGIN
    UPDATE contact3                          
    SET notes = REPLACE(notes, @searchColumnValue, @replaceColumnValue)  

    FETCH NEXT FROM replace_cursor
    INTO @searchColumnValue , @replaceColumnValue
END 
CLOSE replace_cursor
DEALLOCATE replace_cursor
</code></pre>