Solved

Find and Replace Data within a whole table

Posted on 2009-07-09
3
411 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

777 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