Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Replacing Text in an Entire Table (Easy one!)

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2011-11-30 : 15:41:07
Hi All - We have an issue with one of our flat files where alot of the values for NVARCHAR fields are appended with special character "-á"

I have about 70 columns. I'm currently using the REPLACE function below, however I don't want to repeat it for all 70 columns. Is there a function/procedure that can repeat it for all columns?

THANKS!


UPDATE ProductExportList
SET [Rep Name] = REPLACE ([Rep Name],'-á','')

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-11-30 : 16:10:59
In SSMS, set the output to text and execute this. Then copy/paste the results back in and execute them.

SELECT 'UPDATE ProductExportList SET [' + name + '] = REPLACE([' + name + '],''-á'','''');
GO'
FROM sys.columns
WHERE object_id = object_id('ProductExportList')
Go to Top of Page
   

- Advertisement -