Solved

Find and Replace Data within a whole table

Posted on 2009-07-09
3
414 Views
Last Modified: 2012-06-27
I'm trying to update a entire table.  I don't just want to update one column but any of them that contain a character.  Is there a way to do one on all the columns rather than a separate statement for each column?
0
Comment
Question by:N R
[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
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24818145
No,you have to write different statements for each of these columns
0
 
LVL 11

Author Closing Comment

by:N R
ID: 31601823
Well that sucks, ok thanks.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24818232
you can generate the statements like this , run the query, copy -paste the results in a new query window

SELECT 'UPDATE  '+TABLE_NAME +' SET  '+ COLUMN_NAME +'  = REPLACE  ( '+COLUMN_NAME+', ''abc'', ''cde'' ) '
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'PutTableNameHere' AND DATA_TYPE IN ('Varchar', 'nvarchar', 'char','nchar')
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

707 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