Solved

replace, text datatype

Posted on 2010-08-27
4
259 Views
Last Modified: 2012-08-13
in table1
column1
replace
'\\\\'
with
''

datatype is text, so this does not work

UPDATE table1
SET column1 = REPLACE(column1, '\\\\', '')
WHERE CHARINDEX('\\\\', column1) > 0
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:avarmaavarma
ID: 33544779
Try using a LIKE in your where clause

UPDATE table1
SET column1 = REPLACE(column1, '\\\\', '')
WHERE column1 LIKE '%\\\\%'
0
 
LVL 4

Accepted Solution

by:
MSSystems earned 500 total points
ID: 33544788
Try this
UPDATE table1
SET column1 = REPLACE(cast(column1 as varchar(20)), '\\\\', '')
WHERE CHARINDEX('\\\\', column1) > 0 

Open in new window

0
 
LVL 4

Expert Comment

by:MSSystems
ID: 33544942
avarmaavarma:
I the replace function will work against a text data type. I am sure there are other ways, but I think you have to use the UPDATETEXT function for NTEXT Data Types.

0
 

Author Closing Comment

by:rgb192
ID: 33545657
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
INSERT DATE FROM STRING COLUMN 18 67
Help with simplifying SQL 6 55
Loops and updating in SQL Query 9 72
Need help separating values from a column and creating a new record 6 71
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question